home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 12331 / 12331.xpi / chrome / content / aniweather.js next >
Text File  |  2010-01-25  |  157KB  |  4,557 lines

  1.  
  2. if (typeof AniWeatherObj == 'undefined')
  3. {
  4.     var AniWeatherObj = {};
  5. }
  6.  
  7. AniWeatherObj.Environment = function()
  8. {
  9.     this.locale = "";
  10.     this.form = "";
  11.     this.ut = "";
  12.     this.ud = "";
  13.     this.us = "";
  14.     this.up = "";
  15.     this.ur = "";
  16.     
  17.     this.clone = function(info)
  18.     {
  19.         if(typeof info == "undefined")
  20.             return; 
  21.     
  22.         this.locale = info.locale;
  23.         this.form = info.form;
  24.         this.ut = info.ut ;
  25.         this.ud = info.ud ;
  26.         this.us = info.us;
  27.         this.up = info.up;
  28.         this.ur = info.ur;
  29.     }    
  30. }
  31.  
  32. AniWeatherObj.Link = function()
  33. {
  34.     this.title = "";
  35.     this.link = "";
  36.     
  37.     this.clone = function(info)
  38.     {
  39.         if(typeof info == "undefined")
  40.             return; 
  41.     
  42.         this.title = info.title;
  43.         this.link = info.link;
  44.     }        
  45. }
  46.  
  47. AniWeatherObj.LocationPara = function()
  48. {
  49.     this.zipcode = "";    
  50.     this.city = "";
  51.     this.county = ""; 
  52.     
  53.     this.localId = ""; 
  54.     this.name = "";
  55.     this.localtime = "";
  56.     this.latitue = "";
  57.     this.longitude = "";
  58.     this.sunrise = "";
  59.     this.sunset = "";
  60.     this.zone = "";    
  61.     
  62.     this.clone = function(info)
  63.     {
  64.         if(typeof info == "undefined")
  65.             return; 
  66.             
  67.         this.zipcode = info.zipcode;    
  68.         
  69.         this.city = info.city;
  70.         this.county = info.county; 
  71.         
  72.         this.localId = info.localId; 
  73.         this.name = info.name;
  74.         this.localtime = info.localtime;
  75.         this.latitue = info.latitue;
  76.         this.longitude = info.longitude;
  77.         this.sunrise = info.sunrise;
  78.         this.sunset = info.sunset;
  79.         this.zone = info.zone;
  80.     }    
  81. }
  82.  
  83. AniWeatherObj.DisplayLevel = function(show, condicon, conddesc, temp)
  84. {
  85.     this.show = show; 
  86.     this.showicon = condicon;
  87.     this.showdesc = conddesc;
  88.     this.showtemp = temp; 
  89. }
  90.  
  91. AniWeatherObj.GraphInfo = function(name, ctrlName, desc)
  92. {
  93.     this.name = name; 
  94.     this.ctrlName = ctrlName;
  95.     this.desc = desc;
  96. }
  97.  
  98. AniWeatherObj.GraphLevel = function(show, width, height, animation)
  99. {
  100.     this.show = show; 
  101.     this.width = width;
  102.     this.height = height;
  103.     this.animation = animation; 
  104. }
  105.  
  106. AniWeatherObj.ConfigPara = function()
  107. {
  108.     this.buildNo = 0; 
  109.     this.tempUnit = 0; 
  110.     this.windUnit = 0; 
  111.     this.locInfo = [];
  112.     this.defaultLocId = -1;
  113.     this.weatherWidth = 0; 
  114.     this.weatherHeight = 0; 
  115.     this.fadingRatio = 0; 
  116.     this.fadingColor = 0; 
  117.     this.noticeSpan = 1; 
  118.     this.displayMode = 0; 
  119.     this.startNotice = 1; 
  120.     this.useMiniFrame = 0; 
  121.     this.displayPosition = "";
  122.     this.displayOffset = -1;
  123.     this.graphPreviewWidth = 362;     
  124.     this.previewDelay = 600;     
  125.     
  126.     this.displayLevel = [];
  127.     this.graphLevel = [];
  128.     
  129.     this.parseChromeSetting = function(value)
  130.     {
  131.         this.initDefaultPref(); 
  132.         if(value.length > 0)
  133.         {
  134.             try{
  135.                 var aryValues = value.split('&'); 
  136.                 var len = aryValues.length; 
  137.                 
  138.                 this.tempUnit = parseInt(aryValues[0]);  
  139.                 this.buildNo = parseInt(aryValues[1]); 
  140.                 this.defaultLocId = parseInt(aryValues[2]); 
  141.                 var strName = unescape(aryValues[3]); 
  142.                 var strId = aryValues[4];
  143.                 this.windUnit = parseInt(aryValues[5]);  
  144.                 var aryId = strId.split('|'); 
  145.                 var aryName = strName.split('|'); 
  146.  
  147.                 this.locInfo = [];
  148.                 var len = Math.min(aryId.length, aryName.length);
  149.                 for(var i=0;i<len;i++)
  150.                 {
  151.                     this.locInfo.push({'name':aryName[i],'id':aryId[i]}); 
  152.                 }
  153.  
  154.                 if(typeof aryValues[13] == 'undefined')
  155.                     throw "err 01"; 
  156.                 
  157.                 this.weatherWidth = parseInt(aryValues[6]); 
  158.                 this.weatherHeight = parseInt(aryValues[7]); 
  159.                 this.fadingRatio = parseInt(aryValues[9]); 
  160.                 this.fadingColor = aryValues[10]; 
  161.                 this.noticeSpan = parseInt(aryValues[11]); 
  162.                 this.displayMode = parseInt(aryValues[12]); 
  163.                 this.startNotice = parseInt(aryValues[13]); 
  164.                 this.useMiniFrame = (typeof aryValues[15] == 'undefined') ? 0 : parseInt(aryValues[15]); 
  165.                 this.graphPreviewWidth = (typeof aryValues[16] == 'undefined') ? 362 : parseInt(aryValues[16]); 
  166.                 this.previewDelay = (typeof aryValues[17] == 'undefined') ? 500 : parseInt(aryValues[17]); 
  167.                 
  168.                 if(typeof aryValues[8] != 'undefined')
  169.                 {
  170.                     var strLevels = aryValues[8]; 
  171.                     aryLevels = strLevels.split('|'); 
  172.                     var len = aryLevels.length; 
  173.                     var defOp = new Array(0,0,0,0); 
  174.                     var defCurrentOp = new Array(1,1,0,1); 
  175.                     
  176.                     var aryOps = len > 0 ? aryLevels[0].split(',') : defCurrentOp;
  177.                     this.displayLevel['current'] = new AniWeatherObj.DisplayLevel(aryOps[0], aryOps[1], aryOps[2], aryOps[3]); 
  178.                     
  179.                     aryOps = len > 1 ? aryLevels[1].split(',') : defOp;
  180.                     this.displayLevel['today'] = new AniWeatherObj.DisplayLevel(aryOps[0], aryOps[1], aryOps[2], aryOps[3]); 
  181.             
  182.                     aryOps = len > 2 ? aryLevels[2].split(',') : defOp;
  183.                     this.displayLevel['2nd'] = new AniWeatherObj.DisplayLevel(aryOps[0], aryOps[1], aryOps[2], aryOps[3]); 
  184.  
  185.                     aryOps = len > 3 ? aryLevels[3].split(',') : defOp;
  186.                     this.displayLevel['3rd'] = new AniWeatherObj.DisplayLevel(aryOps[0], aryOps[1], aryOps[2], aryOps[3]); 
  187.             
  188.                     aryOps = len > 4 ? aryLevels[4].split(',') : defOp;
  189.                     this.displayLevel['4th'] = new AniWeatherObj.DisplayLevel(aryOps[0], aryOps[1], aryOps[2], aryOps[3]);             
  190.             
  191.                     aryOps = len > 5 ? aryLevels[5].split(',') : defOp;
  192.                     this.displayLevel['5th'] = new AniWeatherObj.DisplayLevel(aryOps[0], aryOps[1], aryOps[2], aryOps[3]); 
  193.                     
  194.                 }
  195.                 
  196.                 if(typeof aryValues[14] != 'undefined')
  197.                 {
  198.                     var strGraphs = aryValues[14]; 
  199.                     aryGraphs = strGraphs.split('|'); 
  200.                     this.graphLevel = [];    
  201.                     var len = aryGraphs.length; 
  202.                     var defOp = new Array(0,0); 
  203.                     
  204.                     var aryOps = len > 0 ? aryGraphs[0].split(',') : defOp; 
  205.                     this.graphLevel['national'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]); 
  206.                     
  207.                     aryOps = len > 1 ? aryGraphs[1].split(',') : defOp; 
  208.                     this.graphLevel['vapor'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]); 
  209.                     
  210.                     aryOps = len > 2 ? aryGraphs[2].split(',') : defOp; 
  211.                     this.graphLevel['radar'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280,  aryOps[1]); 
  212.             
  213.                     aryOps = len > 3 ? aryGraphs[3].split(',') : defOp; 
  214.                     this.graphLevel['uv'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]); 
  215.  
  216.                     aryOps = len > 4 ? aryGraphs[4].split(',')  : defOp; 
  217.                     this.graphLevel['pop'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]); 
  218.             
  219.                     aryOps = len > 5 ? aryGraphs[5].split(',') : defOp; 
  220.                     this.graphLevel['high'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]);             
  221.                     
  222.                     aryOps = len > 6 ? aryGraphs[6].split(',')  : defOp; 
  223.                     this.graphLevel['air'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]);             
  224.                     
  225.                     aryOps = len > 7 ? aryGraphs[7].split(',')  : defOp; 
  226.                     this.graphLevel['alert'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]);             
  227.                 }
  228.             }catch(e){}
  229.         }    
  230.     }
  231.     
  232.     this.initDefaultPref = function()
  233.     {
  234.         this.tempUnit = 0;  
  235.         this.windUnit = 0;  
  236.         this.buildNo = 0; 
  237.         this.defaultLocId = 0; 
  238.         var strId = 'USNY0996|USIL0225|USCA0987|CHXX0008|FRXX0076'; 
  239.         var strName = 'New York, NY|Chicago, IL|San Francisco, CA|Beijing, China|Paris, France'; 
  240.         var aryId = strId.split('|'); 
  241.         var aryName = strName.split('|'); 
  242.         
  243.         this.locInfo = [];
  244.         var len = Math.min(aryId.length, aryName.length);
  245.         for(var i=0;i<len;i++)
  246.         {
  247.             this.locInfo.push({'name':aryName[i],'id':aryId[i]}); 
  248.         }
  249.  
  250.         this.weatherWidth = 640; 
  251.         this.weatherHeight = 436; 
  252.         
  253.         this.fadingRatio = 80; 
  254.         this.fadingColor = "#000000"; 
  255.         this.noticeSpan = 2; 
  256.         this.displayMode = 0; 
  257.         this.startNotice = 1; 
  258.         this.useMiniFrame = 0; 
  259.         this.displayPosition = "status-bar"; 
  260.         this.displayOffset = -1; 
  261.         this.graphPreviewWidth = 362;     
  262.         this.previewDelay = 600;     
  263.         
  264.         this.displayLevel['current'] = new AniWeatherObj.DisplayLevel(1,1,0,1); 
  265.         this.displayLevel['today'] = new AniWeatherObj.DisplayLevel(1,1,0,1); 
  266.         this.displayLevel['2nd'] = new AniWeatherObj.DisplayLevel(0,1,0,1); 
  267.         this.displayLevel['3rd'] = new AniWeatherObj.DisplayLevel(0,1,0,1); 
  268.         this.displayLevel['4th'] = new AniWeatherObj.DisplayLevel(0,1,0,1);             
  269.         this.displayLevel['5th'] = new AniWeatherObj.DisplayLevel(0,1,0,1);         
  270.         
  271.         this.graphLevel['national'] = new AniWeatherObj.DisplayLevel(0,0); 
  272.         this.graphLevel['vapor'] = new AniWeatherObj.DisplayLevel(1,0); 
  273.         this.graphLevel['radar'] = new AniWeatherObj.DisplayLevel(0,0); 
  274.         this.graphLevel['uv'] = new AniWeatherObj.DisplayLevel(0,0); 
  275.         this.graphLevel['pop'] = new AniWeatherObj.DisplayLevel(0,0); 
  276.         this.graphLevel['high'] = new AniWeatherObj.DisplayLevel(0,0);             
  277.         this.graphLevel['air'] = new AniWeatherObj.DisplayLevel(0,0);             
  278.         this.graphLevel['alert'] = new AniWeatherObj.DisplayLevel(1,0);             
  279.     }
  280.     
  281.     this.copyConfig = function(config)
  282.     {
  283.         this.tempUnit = config.tempUnit;
  284.         this.windUnit = config.windUnit;
  285.         this.buildNo = config.buildNo;
  286.         this.defaultLocId = config.defaultLocId; 
  287.         this.locInfo = config.locInfo.slice();
  288.         
  289.         this.weatherWidth = config.weatherWidth; 
  290.         this.weatherHeight = config.weatherHeight; 
  291.         this.fadingRatio  = config.fadingRatio;
  292.         this.fadingColor  = config.fadingColor;
  293.         this.noticeSpan   = config.noticeSpan; 
  294.         this.displayMode   = config.displayMode; 
  295.         this.startNotice   = config.startNotice; 
  296.         this.useMiniFrame   = config.useMiniFrame; 
  297.         this.displayPosition   = config.displayPosition; 
  298.         this.displayOffset   = config.displayOffset; 
  299.         this.graphPreviewWidth = config.graphPreviewWidth;        
  300.         this.previewDelay = config.previewDelay;        
  301.         
  302.         this.displayLevel['current'] = config.displayLevel['current']; 
  303.         this.displayLevel['today'] = config.displayLevel['today']; 
  304.         this.displayLevel['2nd'] = config.displayLevel['2nd']; 
  305.         this.displayLevel['3rd'] = config.displayLevel['3rd']; 
  306.         this.displayLevel['4th'] = config.displayLevel['4th'];     
  307.         this.displayLevel['5th'] = config.displayLevel['5th']; 
  308.         
  309.         this.graphLevel['national'] = config.graphLevel['national']; 
  310.         this.graphLevel['vapor'] = config.graphLevel['vapor']; 
  311.         this.graphLevel['radar'] = config.graphLevel['radar']; 
  312.         this.graphLevel['uv'] = config.graphLevel['uv']; 
  313.         this.graphLevel['pop'] = config.graphLevel['pop']; 
  314.         this.graphLevel['high'] = config.graphLevel['high'];     
  315.         this.graphLevel['air'] = config.graphLevel['air'];     
  316.         this.graphLevel['alert'] = config.graphLevel['alert'];     
  317.     }
  318. }
  319.  
  320. AniWeatherObj.DailyWeatherInfo = function()
  321. {
  322.     this.highTemp = 0; 
  323.     this.lowTemp = 0; 
  324.     this.sunrise = "";
  325.     this.sunset = "";
  326.  
  327.     this.weekday = "";
  328.     this.date = "";
  329.     this.dayicon = "";
  330.     this.daycond = "";
  331.     this.daywindspeed = "";
  332.     this.daywinddir = "";
  333.     this.dayppcp = "";
  334.     this.dayhumid = "";
  335.  
  336.     this.nighticon = "";
  337.     this.nightcond = "";
  338.     this.nightwindspeed = "";
  339.     this.nightwinddir = "";
  340.     this.nightppcp = "";
  341.     this.nighthumid = "";
  342. }
  343.  
  344. AniWeatherObj.GeneralWeather = function()
  345. {
  346.     this.locname = "";
  347.     this.dayName = "";
  348.     this.icon = "";
  349.     this.cond = "";
  350.     this.windcond = "";
  351.     this.tempval = "";
  352.     this.vis = "";
  353.     this.humid = "";
  354.     this.uv = "";
  355.     this.ppcp = ""; 
  356.     this.width = "";
  357.     this.height = "";
  358.     this.fadingRatio = 0;
  359.     this.fadingColor = "";
  360.     this.noticeSpan = 0;    
  361.     this.displayMode = 0;    
  362.     this.animate = false; 
  363.     this.moonphase = 15;
  364.     this.useMiniFrame = 0; 
  365.     
  366.     this.sunrise = "";
  367.     this.sunset = "";
  368.     this.nighticon = "";
  369.     this.nightcond = "";
  370.     this.nightppcp = "";
  371.     this.nighthumid = "";
  372.     this.nightwindcond = "";
  373.     this.nighttemp;
  374.     
  375.     this.graphId = "";
  376.     this.graphDesc = "";
  377.     this.graphAnimation = "";
  378.     this.daypart = "";
  379.     
  380.     this.clone = function(info)
  381.     {
  382.         if(typeof info == "undefined")
  383.             return; 
  384.     
  385.         this.locname = info.locname;
  386.         this.dayName = info.dayName;
  387.         this.icon = info.icon;
  388.         this.cond = info.cond;
  389.         this.daypart = info.daypart;
  390.         this.windcond = info.windcond;
  391.         this.tempval = info.tempval;
  392.         this.vis = info.vis;
  393.         this.humid = info.humid;
  394.         this.uv = info.uv;
  395.         this.ppcp = info.ppcp; 
  396.         this.width = info.width;
  397.         this.height = info.height;
  398.         this.fadingRatio = info.fadingRatio;
  399.         this.fadingColor = info.fadingColor;
  400.         this.noticeSpan = info.noticeSpan;    
  401.         this.displayMode = info.displayMode;    
  402.         this.animate = info.animate; 
  403.         this.moonphase = info.moonphase; 
  404.         this.sunrise = info.sunrise; 
  405.         this.sunset = info.sunset; 
  406.         this.nighticon = info.nighticon;
  407.         this.nightcond = info.nightcond;
  408.         this.nightppcp = info.nightppcp;
  409.         this.nighthumid = info.nighthumid;
  410.         this.nightwindcond = info.nightwindcond;
  411.         this.nighttemp = info.nighttemp;
  412.         this.useMiniFrame = info.useMiniFrame;
  413.         
  414.         this.graphId = info.graphId;
  415.         this.graphDesc = info.graphDesc;
  416.         this.graphAnimation = info.graphAnimation;
  417.     }    
  418. }
  419.  
  420. AniWeatherObj.CurrentWeather = function()
  421. {
  422.     this.position = "";
  423.     this.temp = ""; 
  424.     this.feellike = "";
  425.     this.time = "";
  426.     this.condition = "";
  427.     this.icon = "";
  428.     this.windspeed = "";
  429.     this.winddir = "";
  430.     this.humid = "";
  431.     this.visible = "";
  432.     this.uvvalue = "";
  433.     this.uvlevel = "";
  434.     this.moonicon = "";
  435.     this.moondesc = "";
  436.     
  437.     this.clone = function(info)
  438.     {
  439.         if(typeof info == "undefined")
  440.             return; 
  441.     
  442.         this.position = info.position;
  443.         this.temp = info.temp; 
  444.         this.feellike = info.feellike;
  445.         this.time = info.time;
  446.         this.condition = info.condition;
  447.         this.icon = info.icon;
  448.         this.windspeed = info.windspeed;
  449.         this.winddir = info.winddir;
  450.         this.humid = info.humid;
  451.         this.visible = info.visible;
  452.         this.uvvalue = info.uvvalue;
  453.         this.uvlevel = info.uvlevel;
  454.         this.moonicon = info.moonicon;
  455.         this.moondesc = info.moondesc;    
  456.     }
  457. }
  458.  
  459. AniWeatherObj.WeatherInfo = function()
  460. {
  461.     this.locationInfo = new  AniWeatherObj.LocationPara(); 
  462.     this.currentInfo = new AniWeatherObj.CurrentWeather(); 
  463.     this.envInfo = new AniWeatherObj.Environment(); 
  464.     
  465.     this.links = new Array; 
  466.     this.dailyInfo = new Array;
  467.     
  468.     this.passToday = false; 
  469.     
  470.     this.dates = "";
  471.     this.days = "";
  472.     
  473.     this.copyWeatherInfo = function(weatherInfo)
  474.     {
  475.         this.locationInfo.clone(weatherInfo.locationInfo); 
  476.         this.currentInfo.clone(weatherInfo.currentInfo); 
  477.         this.envInfo.clone(weatherInfo.evtInfo);
  478.         
  479.         this.links = weatherInfo.links.slice(); 
  480.         this.dailyInfo = weatherInfo.dailyInfo.slice(); 
  481.         
  482.         this.dates = weatherInfo.dates;
  483.         this.days = weatherInfo.days;    
  484.         this.passToday = weatherInfo.passToday; 
  485.     }
  486.     
  487. }    
  488.  
  489. AniWeatherObj.ChromeRes = function() 
  490. {
  491.     var aryResChrome = new Object;
  492.     
  493.     var resID = -1;
  494.     
  495.     var totalItemNm;     
  496.     var commExt = null; 
  497.     
  498.     var arySettings = new Array; 
  499.     var resIdx = 0;
  500.     this.RegisterResource = function (ResName, ResValue) 
  501.     {
  502.         if(ResName != undefined && ResName.toString().length)
  503.             aryResChrome[ResName] = ResValue;
  504.     };
  505.     
  506.     this.GetResourceByName = function(ResName)
  507.     {
  508.         if(ResName != undefined && ResName.toString().length)
  509.         {
  510.             return (aryResChrome[ResName] == undefined) ? "" : aryResChrome[ResName];
  511.         }
  512.         else
  513.             return "";
  514.     };   
  515.     
  516.     this.prepareSettings = function(arySetting)
  517.     {
  518.         var strInfo = "";
  519.         arySettings.push(strInfo);
  520.     }
  521.  
  522.     this.getResourceSet = function ()
  523.     {
  524.         try{
  525.             // Content script
  526.             commExt = chrome.extension.connect();
  527.             commExt.onMessage.addListener(function(message) {
  528.               switch(message.mode)
  529.               {
  530.                 case 0: //. Connecting
  531.                     // commExt.postMessage({'purpose': 'init'});
  532.                     break;
  533.                 case 1: //. Initliazation
  534.                     if(message.status == 0) //. Success
  535.                     {
  536.                         commExt.postMessage({'purpose': 'set', 'name': 'General', 'value' : arySettings[resIdx]});                    
  537.                     }
  538.                     break;                
  539.                 case 2: //. Add item
  540.                 {
  541.                     break;
  542.                 }
  543.               }
  544.             });
  545.         }catch(e){/*alert(e.toString());*/}
  546.         return false; 
  547.     }
  548.     
  549.     this.setResourceSet = function (aryPara)
  550.     {
  551.         if(!commExt)
  552.         {
  553.             return; 
  554.         }
  555.         
  556.         this.prepareSettings(aryPara); 
  557.         try{
  558.             commExt.postMessage({'purpose': 'init'});
  559.         }catch(e){}
  560.         
  561.         return false; 
  562.  
  563.     }    
  564.     
  565.     this.InitializeRes = function()
  566.     {
  567.         if(this.getResourceSet() == false)
  568.         {
  569.             this.RegisterResource('aniweather.sitebase', 'http://www.aniweather.com/'); 
  570.             this.RegisterResource('aniweather.mediabase', 'http://aniweather.s3.amazonaws.com/'); 
  571.         }            
  572.     };
  573. }
  574.  
  575. AniWeatherObj.IERes = function() 
  576. {
  577.     var aryResIE = new Object;
  578.     
  579.     this.RegisterResource = function (ResName, ResValue) 
  580.     {
  581.         if(ResName != undefined && ResName.toString().length)
  582.             aryResIE[ResName] = ResValue;
  583.     };
  584.     
  585.     this.GetResourceByName = function(ResName)
  586.     {
  587.         if(ResName != undefined && ResName.toString().length)
  588.             return (aryResIE[ResName] == undefined) ? "" : aryResIE[ResName];
  589.         else
  590.             return "";
  591.     };    
  592.     
  593.     this.InitializeRes = function()
  594.     {
  595.         if(typeof _AniWeatherIEObj != 'undefined')
  596.         {
  597.             var _DefaultObj = new _AniWeather.IEDefaultRes;
  598.             aryResIE = _DefaultObj.GetDefaultRes();             
  599.         }
  600.     };
  601. }
  602.  
  603. AniWeatherObj.Theme = function()
  604. {
  605.     this.clrBorder="";
  606.     this.clrTitle="";
  607.     this.clrInput="";
  608.     this.clrBackground="";
  609.     this.urlMore="";
  610.     this.urlResize="";
  611. }
  612.  
  613. AniWeatherObj.LocSearchInfo = function()
  614. {
  615.     this.locId = "";
  616.     this.name = "";
  617.     this.type = "";
  618. }
  619.  
  620. AniWeatherObj.BrowserAgent = function() 
  621. {
  622.        
  623.     var BROWSER_NONE = 0;
  624.     var BROWSER_IE = 1;
  625.     var BROWSER_FF = 2;
  626.     var BROWSER_CHROME = 3; 
  627.  
  628.     var browserType; ;
  629.     if(navigator.userAgent.indexOf("MSIE") >= 0)
  630.         browserType = BROWSER_IE;
  631.     else if(navigator.userAgent.toLowerCase().indexOf("gecko/") >= 0)
  632.         browserType = BROWSER_FF;    
  633.     else if(navigator.userAgent.toLowerCase().indexOf("chrome") >= 0)
  634.         browserType = BROWSER_CHROME;                
  635.     else
  636.         browserType = BROWSER_FF;
  637.     
  638.     var LEFTBUTTON         = (browserType == BROWSER_IE) ? 1 : 0; 
  639.     var RIGHTBUTTON     = (browserType == BROWSER_IE) ? 2 : 2; 
  640.     var MIDDLEBUTTON     = (browserType == BROWSER_IE) ? 4 : 1; 
  641.     
  642.     var aryLocalString; 
  643.     function getLocaleStringBundle()
  644.     { 
  645.         if(browserType == BROWSER_FF)
  646.         {
  647.             var src = "chrome://aniweather/locale/global.properties";
  648.           var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
  649.            .getService(Components.interfaces.nsIStringBundleService);
  650.           var Bundle = stringBundleService.createBundle(src);
  651.           return Bundle;
  652.       }
  653.       else
  654.         return null;   
  655.     }
  656.  
  657.     function getLocaleString(strName)
  658.     { 
  659.         
  660.         if(browserType == BROWSER_FF)
  661.         {
  662.             try{
  663.                 if(aryLocalString)  
  664.                     return aryLocalString.GetStringFromName(strName);
  665.                 else
  666.                 return "";
  667.             }
  668.             catch(err){
  669.                 loghelper("Error in getting resource: " + strName); 
  670.                 return "";
  671.             }            
  672.         }
  673.         else if(browserType == BROWSER_IE)
  674.         {
  675.             return objCleekiIERes.GetResourceByName(strName);
  676.         }
  677.         else if(browserType == BROWSER_CHROME)
  678.         {
  679.             return objCleekiChromeRes.GetResourceByName(strName);
  680.         }
  681.         else
  682.         {
  683.             return "";
  684.         }
  685.     }
  686.  
  687.     function getLocaleStringFormatted(strName, args)
  688.     { 
  689.         if(browserType == BROWSER_FF)
  690.         {
  691.             if(aryLocalString)  
  692.             return aryLocalString.formatStringFromName(strName, args, args.length);
  693.           else
  694.             return "";
  695.         }
  696.         else if(browserType == BROWSER_IE)
  697.         {
  698.             return objCleekiIERes.GetResourceByName(strName);
  699.         }        
  700.         else
  701.         {
  702.             return getLocaleString(strName);
  703.         }
  704.           
  705.     }
  706.  
  707.     aryLocalString = getLocaleStringBundle();
  708.      
  709.     var aryGraphInfo = [];     
  710.     aryGraphInfo['national'] = new AniWeatherObj.GraphInfo('national', 'National', getLocaleString('graph.desc.national')); 
  711.     aryGraphInfo['vapor'] = new AniWeatherObj.GraphInfo('vapor', 'Vapor', getLocaleString('graph.desc.satellite'));     
  712.     aryGraphInfo['radar'] = new AniWeatherObj.GraphInfo('radar', 'Radar', getLocaleString('graph.desc.radar'));     
  713.     aryGraphInfo['uv'] = new AniWeatherObj.GraphInfo('uv', 'UV', getLocaleString('graph.desc.uv'));     
  714.     aryGraphInfo['pop'] = new AniWeatherObj.GraphInfo('pop', 'Pop', getLocaleString('graph.desc.precipitation'));     
  715.     aryGraphInfo['high'] = new AniWeatherObj.GraphInfo('high', 'High', getLocaleString('graph.desc.temperature'));     
  716.     aryGraphInfo['air'] = new AniWeatherObj.GraphInfo('air', 'Air', getLocaleString('graph.desc.air'));     
  717.     aryGraphInfo['alert'] = new AniWeatherObj.GraphInfo('alert', 'Alert', getLocaleString('graph.desc.alerts'));     
  718.     
  719.     var aryTWCLinks = []; 
  720.     aryTWCLinks['Local Pollen Reports'] = 0; 
  721.     aryTWCLinks['Airport Conditions'] = 1; 
  722.     aryTWCLinks['Picnic Weather'] = 2; 
  723.     aryTWCLinks['Rush Hour Traffic'] = 3; 
  724.     aryTWCLinks['Lawn and Garden Weather'] = 4; 
  725.     
  726.     var MIN_LAUNCHER_WIDTH = 480; 
  727.     var MIN_LAUNCHER_HEIGHT = 360; 
  728.     var GOOGLEICONBASE = "http://www.google.com";
  729.     //var WEEKDAYS = new Array(getLocaleString('weekdays.sun'),getLocaleString('weekdays.mon'),getLocaleString('weekdays.tue'),getLocaleString('weekdays.wed'),getLocaleString('weekdays.thu'),getLocaleString('weekdays.fri'),getLocaleString('weekdays.sat'),getLocaleString('weekdays.sun'),getLocaleString('weekdays.mon'),getLocaleString('weekdays.tue'),getLocaleString('weekdays.wed'),getLocaleString('weekdays.thu'),getLocaleString('weekdays.fri'),getLocaleString('weekdays.sat')); 
  730.     var WEEKDAYS = new Array(); 
  731.     WEEKDAYS[0] = getLocaleString('weekdays.sun'); 
  732.     WEEKDAYS[1] = getLocaleString('weekdays.mon'); 
  733.     WEEKDAYS[2] = getLocaleString('weekdays.tue'); 
  734.     WEEKDAYS[3] = getLocaleString('weekdays.wed'); 
  735.     WEEKDAYS[4] = getLocaleString('weekdays.thu'); 
  736.     WEEKDAYS[5] = getLocaleString('weekdays.fri'); 
  737.     WEEKDAYS[6] = getLocaleString('weekdays.sat'); 
  738.     WEEKDAYS[7] = getLocaleString('weekdays.sun'); 
  739.     WEEKDAYS[8] = getLocaleString('weekdays.mon'); 
  740.     WEEKDAYS[9] = getLocaleString('weekdays.tue'); 
  741.     WEEKDAYS[10] = getLocaleString('weekdays.wed'); 
  742.     WEEKDAYS[11] = getLocaleString('weekdays.thu'); 
  743.     WEEKDAYS[12] = getLocaleString('weekdays.fri'); 
  744.     WEEKDAYS[13] = getLocaleString('weekdays.sat'); 
  745.     
  746.     var RAWWEEKDAYS = new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); 
  747.     
  748.     var FULLWEEKDAY = new Array();
  749.     FULLWEEKDAY['Now'] = getLocaleString('fullweekday.now');
  750.     FULLWEEKDAY['Today'] = getLocaleString('fullweekday.today');
  751.     FULLWEEKDAY['Sun'] = getLocaleString('fullweekday.sun');
  752.     FULLWEEKDAY['Mon'] = getLocaleString('fullweekday.mon');
  753.     FULLWEEKDAY['Tue'] = getLocaleString('fullweekday.tue');
  754.     FULLWEEKDAY['Wed'] = getLocaleString('fullweekday.wed');
  755.     FULLWEEKDAY['Thu'] = getLocaleString('fullweekday.thu');
  756.     FULLWEEKDAY['Fri'] = getLocaleString('fullweekday.fri');
  757.     FULLWEEKDAY['Sat'] = getLocaleString('fullweekday.sat');
  758.     
  759.     var MONTHS = new Array("01","02","03","04","05","06","07","08","09","10","11","12"); 
  760.     var forecastWeatherFeed = 'http://xoap.weather.com/weather/local/[locid]?cc=*&dayf=5&link=xoap&prod=xoap&par=1106689085&key=3d761e6de925aa0d'; 
  761.     var currentWeatherFeed = 'http://xoap.weather.com/weather/local/[locid]?cc=*&link=xoap&prod=xoap&par=1106689085&key=3d761e6de925aa0d'; 
  762.     var settingPageName = "aniweather.config7.html";
  763.     var aniweatherHostName = "www.aniweather.com";
  764.     var feedbackPageName = "php/feedback.php";
  765.     var locSearchBase = 'http://xoap.weather.com/search/search?where=';
  766.     var weatherSiteBase = 'http://www.aniweather.com/'; 
  767.     var weatherMediaBase = 'http://aniweather.s3.amazonaws.com/'; 
  768.     var iconBaseUrl = weatherMediaBase + 'media/weather/'; 
  769.     var tenDaysReportURL = "tenday.html";
  770.     var hourlyReportURL = "hourly.html";    
  771.     var localeId = 'en-US'; 
  772.     
  773.     var WEATHER_UPDATE_NONE = 0; 
  774.     var WEATHER_UPDATE_CURRENT = 1;
  775.     var WEATHER_UPDATE_FORECAST = 2; 
  776.     var WEATHER_UPDATE_ALL = 3;
  777.     var weatherUpdateMode = WEATHER_UPDATE_NONE; 
  778.     
  779.     var eventDoc = null; 
  780.     var aryLocInfo = [];
  781.  
  782.     // var objAWIERes = new AniWeatherObj.IERes(); 
  783.     // var objAWChromeRes = new  AniWeatherObj.ChromeRes(); 
  784.     
  785.     var objConfigPara = new AniWeatherObj.ConfigPara(); 
  786.     var objWeatherInfo = new AniWeatherObj.WeatherInfo(); 
  787.     var objDefaultWeatherInfo = new AniWeatherObj.WeatherInfo(); 
  788.     
  789.     var miniWidth = 240;
  790.     var miniHeight = 256;
  791.     var miniMargin = 32;
  792.     
  793.     var trayWidth = 100;
  794.     var trayHeight = 120; 
  795.     var traySmallWidth = 84;
  796.     var traySmallHeight = 96; 
  797.     
  798.     var DEFAULT_WIDTH = 640; 
  799.     var DEFAULT_HEIGHT = [];
  800.     DEFAULT_HEIGHT[0] = 436; 
  801.     DEFAULT_HEIGHT[1] = 420; 
  802.  
  803.     var extendedWidth = DEFAULT_WIDTH;
  804.     var extendedHeight = DEFAULT_HEIGHT[0];
  805.     
  806.     var CANVAS_HEIGHT = 512; 
  807.     
  808.     var extendedMargin = 32;
  809.     var fadingColor = "#000000";
  810.     var fadingRatio = 80; 
  811.     var noticeSpan = 1; 
  812.     var displayMode = 0; 
  813.     
  814.     var holderMargin = 8; 
  815.     var BUILDNO = 703; 
  816.     var mph2kmh = 1.609;
  817.     var recheckDelay = 30000; 
  818.     
  819.     
  820.     var weatherCityLinkId = 'aniweathercity_';
  821.     var miniWeatherCanvasId = 'divMiniAniWeatherCanvas'; 
  822.     var miniWeatherId = 'divMiniAniWeather';     
  823.     var miniHolderId = 'divMiniAniWeatherHolder';     
  824.     
  825.     var extendedWeatherCanvasId = 'divExtendedAniWeatherCanvas'; 
  826.     var extendedWeatherId = 'divExtendedAniWeather';     
  827.     var extendedHolderId = 'divExtendedAniWeatherHolder';     
  828.     var weatherDashboardId = 'weatherDashboard';     
  829.     var weatherLauncherId = 'weatherLauncher';     
  830.     var weatherLauncherHolderId = 'weatherLauncherHolder';     
  831.     
  832.     var xmlhttp = null;
  833.     var xmlServer = null; 
  834.     
  835.     var displayExtended = false; 
  836.     var timeLastCheck = 0;
  837.     var forecastInterval = 3600000 * 4; //. 4 hr * 3600000 millisec/hr
  838.     var currentInterval = 60000 * 30; //. 30 min * 60000 millisec/min
  839.     var queryStatus = 0; 
  840.     
  841.     var noticeWidth = 240;
  842.     var noticeHeight =104; 
  843.     var noticeMoreHeight =216; 
  844.     
  845.     var defaultGraphWidth = 362; 
  846.     var defaultGraphHeight = 280; 
  847.     
  848.     var noticeTime = 5000; 
  849.     var graphTime = 8000; 
  850.     
  851.     var launcherDist = noticeHeight/2; 
  852.     var launcherTime = 5; 
  853.     var launcherSpeed = launcherDist*2/launcherTime; 
  854.     var launcherAcce = 2*(launcherDist - launcherTime*launcherSpeed)/(launcherTime*launcherTime); 
  855.     var launcherIdx = 0; 
  856.     var tmLauncherAnimation = null; 
  857.     
  858.     var curPort = null; 
  859.     
  860.     var autoNoticeDelay = 5000; 
  861.     
  862.     var checkIndex = 0; 
  863.  
  864.     var tmLauncher = null; 
  865.     var tmSetPanelIcon = null; 
  866.     var docLauncher = null; 
  867.     
  868.     var weatherHelperString = "";
  869.     var weatherDefaultString = "";
  870.     
  871.     var lstReportId = {'current':0, 'today':1, '2nd':2, '3rd':3, '4th':4, '5th':5};
  872.     var currentReportId = ''; 
  873.     var currentGraphId = ''; 
  874.     
  875.     String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }        
  876.     
  877.     this.getCheckIndex = function() 
  878.     {
  879.  
  880.         return checkIndex; 
  881.     }
  882.     
  883.     this.setAniWeather = function()
  884.     {
  885.         var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  886.                            .getService(Components.interfaces.nsIWindowMediator);
  887.         var gBrowser = wm.getMostRecentWindow("navigator:browser").gBrowser;
  888.  
  889.         gBrowser.selectedTab = gBrowser.addTab(this.getSettingPage()) ;
  890.     }
  891.     
  892.     this.getSettingPage = function()
  893.     {
  894.         var aniweatherSettingURL = weatherSiteBase + 'locale/' + localeId +'/'+ settingPageName + '#settings';
  895.         return aniweatherSettingURL; 
  896.     }
  897.     
  898.     this.copyConfig = function(config)
  899.     {
  900.         objConfigPara.copyConfig(config); 
  901.     }
  902.     
  903.     function _attachLocIds(strWeather)
  904.     {
  905.         var num = Math.min(6, objConfigPara.locInfo.length); 
  906.  
  907.         var strLocName = "";
  908.         var strLocId = "";
  909.         for(var i=0;i<num;i++)
  910.         {
  911.             var loc = objConfigPara.locInfo[i];
  912.             
  913.             if(i > 0)
  914.             {
  915.                 strLocName = strLocName + "|";
  916.                 strLocId = strLocId + "|";
  917.             }
  918.             
  919.             strLocName = strLocName + loc.name;
  920.             strLocId = strLocId + loc.id;
  921.         }
  922.         
  923.         strWeather = strWeather + "&cities=" + strLocName + "&locids=" + strLocId;     
  924.  
  925.         return strWeather; 
  926.     }    
  927.     
  928.     this.attachLocIds = function(strWeather)
  929.     {
  930.         return _attachLocIds(strWeather); 
  931.     }
  932.     
  933.     function getObjectByEvent(event)
  934.     {
  935.         if(browserType == BROWSER_IE)
  936.         {
  937.             var objtype = typeof event.srcElement;
  938.             if(objtype.toLowerCase() != "unknown")
  939.                 return event.srcElement;
  940.             else
  941.                 return null; 
  942.           }
  943.         else if(browserType == BROWSER_FF)
  944.             return event.originalTarget;
  945.         else if(browserType == BROWSER_CHROME)
  946.             return event.srcElement;
  947.     }
  948.     
  949.     function getDocumentByEvent(event)
  950.     {
  951.         if(browserType == BROWSER_FF)
  952.             return     event.originalTarget.ownerDocument;
  953.         else
  954.             return document; 
  955.     }
  956.     
  957.     function initPref()
  958.     {
  959.         var re = false; 
  960.         if(browserType == BROWSER_FF)
  961.         {
  962.             var chromeRegService = Components.classes["@mozilla.org/chrome/chrome-registry;1"].getService();
  963.             var xulChromeReg = chromeRegService.QueryInterface(Components.interfaces.nsIXULChromeRegistry);
  964.             var toolkitChromeReg = chromeRegService.QueryInterface(Components.interfaces.nsIToolkitChromeRegistry);
  965.             localeId = xulChromeReg.getSelectedLocale("aniweather");
  966.  
  967.             objConfigPara.tempUnit = getIntPref('tempUnit'); 
  968.             objConfigPara.windUnit = getIntPref('windUnit'); 
  969.             objConfigPara.buildNo = getIntPref('buildNo'); 
  970.             objConfigPara.defaultLocId = getIntPref('defaultLocId'); 
  971.             
  972.             var strId = getCharPref('locId'); 
  973.             // var strName = getCharPref('locName'); 
  974.             var strName = getComplexPref('locName'); 
  975.  
  976.             var aryId = strId.split('|'); 
  977.             var aryName = strName.split('|'); 
  978.             
  979.             objConfigPara.locInfo = [];
  980.             var len = Math.min(aryId.length, aryName.length);
  981.             for(var i=0;i<len;i++)
  982.             {
  983.                 objConfigPara.locInfo.push({'name':aryName[i],'id':aryId[i]}); 
  984.             }
  985.             
  986.             objConfigPara.weatherWidth = getIntPref('weatherWidth'); 
  987.             objConfigPara.weatherHeight = getIntPref('weatherHeight'); 
  988.             objConfigPara.fadingRatio = getIntPref('fadingRatio'); 
  989.             objConfigPara.fadingColor = getCharPref('fadingColor'); 
  990.             objConfigPara.noticeSpan = getIntPref('noticeSpan'); 
  991.             objConfigPara.displayMode = getIntPref('displayMode'); 
  992.             objConfigPara.startNotice = getIntPref('startNotice'); 
  993.             objConfigPara.useMiniFrame = getIntPref('useMiniFrame'); 
  994.             objConfigPara.displayPosition = getCharPref('displayPosition'); 
  995.             objConfigPara.displayOffset = getIntPref('displayOffset'); 
  996.             objConfigPara.graphPreviewWidth = getIntPref('graphPreviewWidth'); 
  997.             objConfigPara.previewDelay = getIntPref('previewDelay'); 
  998.             
  999.             var strLevels = getCharPref('displayLevel'); 
  1000.             aryLevels = strLevels.split('|'); 
  1001.             
  1002.             var aryOps = aryLevels[0].split(','); 
  1003.             objConfigPara.displayLevel['current'] = new AniWeatherObj.DisplayLevel(aryOps[0], aryOps[1], aryOps[2], aryOps[3]); 
  1004.             
  1005.             aryOps = aryLevels[1].split(','); 
  1006.             objConfigPara.displayLevel['today'] = new AniWeatherObj.DisplayLevel(aryOps[0], aryOps[1], aryOps[2], aryOps[3]); 
  1007.     
  1008.             aryOps = aryLevels[2].split(','); 
  1009.             objConfigPara.displayLevel['2nd'] = new AniWeatherObj.DisplayLevel(aryOps[0], aryOps[1], aryOps[2], aryOps[3]); 
  1010.  
  1011.             aryOps = aryLevels[3].split(','); 
  1012.             objConfigPara.displayLevel['3rd'] = new AniWeatherObj.DisplayLevel(aryOps[0], aryOps[1], aryOps[2], aryOps[3]); 
  1013.     
  1014.             aryOps = aryLevels[4].split(','); 
  1015.             objConfigPara.displayLevel['4th'] = new AniWeatherObj.DisplayLevel(aryOps[0], aryOps[1], aryOps[2], aryOps[3]);             
  1016.     
  1017.             aryOps = aryLevels[5].split(','); 
  1018.             objConfigPara.displayLevel['5th'] = new AniWeatherObj.DisplayLevel(aryOps[0], aryOps[1], aryOps[2], aryOps[3]); 
  1019.             
  1020.             var strGraphic = getCharPref('graphicLevel'); 
  1021.             aryGraphs = strGraphic.split('|'); 
  1022.             this.graphLevel = [];    
  1023.             var len = aryGraphs.length; 
  1024.             var defOp = new Array(0,0); 
  1025.             
  1026.             aryOps = len > 0 ? aryGraphs[0].split(',') : defOp;
  1027.             objConfigPara.graphLevel['national'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]); 
  1028.             
  1029.             aryOps = len > 1 ? aryGraphs[1].split(',') : defOp;
  1030.             objConfigPara.graphLevel['vapor'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]); 
  1031.             
  1032.             aryOps = len > 2 ? aryGraphs[2].split(',') : defOp;
  1033.             objConfigPara.graphLevel['radar'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280,  aryOps[1]); 
  1034.             
  1035.             aryOps = len > 3 ? aryGraphs[3].split(',') : defOp;
  1036.             objConfigPara.graphLevel['uv'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]); 
  1037.  
  1038.             aryOps = len > 4 ? aryGraphs[4].split(',') : defOp;
  1039.             objConfigPara.graphLevel['pop'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]); 
  1040.             
  1041.             aryOps = len > 5 ? aryGraphs[5].split(',') : defOp;
  1042.             objConfigPara.graphLevel['high'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]);             
  1043.                     
  1044.             aryOps = len > 6 ? aryGraphs[6].split(',') : defOp;
  1045.             objConfigPara.graphLevel['air'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]);             
  1046.             
  1047.             aryOps = len > 7 ? aryGraphs[7].split(',') : defOp;
  1048.             objConfigPara.graphLevel['alert'] = new AniWeatherObj.GraphLevel(aryOps[0], 360, 280, aryOps[1]);             
  1049.             
  1050.             var firstRun = getIntPref("firstRun"); 
  1051.             if(firstRun)
  1052.             {
  1053.                 setIntPref("firstRun", 0);    
  1054.                 setTimeout(visitWelcomeTimer, 1000); 
  1055.             }    
  1056.             
  1057.             re = true; 
  1058.         }
  1059.         else if(browserType == BROWSER_CHROME)
  1060.         {
  1061.         }
  1062.         
  1063.         return re; 
  1064.     }
  1065.     
  1066.     function visitWelcomeTimer()
  1067.     {
  1068.         var aniweatherWelcomeURL = weatherSiteBase + 'locale/' + localeId +'/'+ settingPageName;
  1069.     
  1070.         gBrowser.selectedTab = gBrowser.addTab(aniweatherWelcomeURL) ;
  1071.     }
  1072.     
  1073.     function updateChromeStatus(status)
  1074.     {
  1075.         if(browserType == BROWSER_CHROME)
  1076.         {
  1077.             document.getElementById("AniWeatherStatus").innerHTML = status;
  1078.         }
  1079.     }
  1080.  
  1081.     
  1082.     function savePref()
  1083.     {
  1084.         var re = false; 
  1085.         try{
  1086.             if(browserType == BROWSER_FF)
  1087.             {
  1088.                 setIntPref('tempUnit', objConfigPara.tempUnit); 
  1089.                 setIntPref('windUnit', objConfigPara.windUnit); 
  1090.                 setIntPref('buildNo', BUILDNO); 
  1091.                 setIntPref('defaultLocId', objConfigPara.defaultLocId); 
  1092.                 // setIntPref('locChanged', 1); 
  1093.  
  1094.                 var strId = "";
  1095.                 var strName = "";
  1096.                 var locNum = objConfigPara.locInfo.length; 
  1097.                 for(var i=0;i<locNum;i++)
  1098.                 {
  1099.                     strName = strName + objConfigPara.locInfo[i].name;
  1100.                     strId = strId + objConfigPara.locInfo[i].id;
  1101.                     
  1102.                     if(i < locNum-1)
  1103.                     {
  1104.                         strName = strName + "|";
  1105.                         strId = strId + "|";
  1106.                     }
  1107.                 }
  1108.                 
  1109.                 setCharPref('locId', strId); 
  1110.                 
  1111.                 // setCharPref('locName', strName); 
  1112.                 setComplexPref('locName', strName); 
  1113.                     
  1114.                 setIntPref('weatherWidth', objConfigPara.weatherWidth); 
  1115.                 setIntPref('weatherHeight', objConfigPara.weatherHeight); 
  1116.                 setIntPref('fadingRatio', objConfigPara.fadingRatio); 
  1117.                 setIntPref('noticeSpan', objConfigPara.noticeSpan); 
  1118.                 setIntPref('displayMode', objConfigPara.displayMode); 
  1119.                 setIntPref('startNotice', objConfigPara.startNotice); 
  1120.                 setIntPref('useMiniFrame', objConfigPara.useMiniFrame); 
  1121.                 setCharPref('fadingColor', objConfigPara.fadingColor); 
  1122.                 setCharPref('displayPosition', objConfigPara.displayPosition); 
  1123.                 setIntPref('displayOffset', objConfigPara.displayOffset); 
  1124.                 setIntPref('graphPreviewWidth', objConfigPara.graphPreviewWidth); 
  1125.                 setIntPref('previewDelay', objConfigPara.previewDelay); 
  1126.                 
  1127.                 positionCanvas(); 
  1128.  
  1129.                 var strLevels = getLevelString(); 
  1130.                 setCharPref('displayLevel', strLevels); 
  1131.  
  1132.                 var strGraphs = getGraphString(); 
  1133.                 setCharPref('graphicLevel', strGraphs); 
  1134.                 
  1135.                 re = true; 
  1136.             }
  1137.             else if(browserType == BROWSER_CHROME)
  1138.             {
  1139.                 var strSetting = _prepareChromeSettingString(); 
  1140.                 if(curPort)
  1141.                     curPort.postMessage({'purpose':'save', 'data':strSetting});                 
  1142.             }
  1143.         }catch(e){return false; }
  1144.         
  1145.         return re; 
  1146.     }    
  1147.     
  1148.     this.onPrefSaved = function(status)
  1149.     {
  1150.         if(status == 0)
  1151.             alert(getLocaleString('alert.applying.setting')); 
  1152.         else
  1153.             alert(getLocaleString('alert.applying.setting.error')); 
  1154.     }
  1155.     
  1156.     function getLevelString()
  1157.     {
  1158.         var level = objConfigPara.displayLevel['current'];
  1159.         var strLevels = level.show+','+level.showicon+','+level.showdesc+','+level.showtemp;
  1160.  
  1161.         level = objConfigPara.displayLevel['today'];
  1162.         strLevels = strLevels + '|'+ level.show+','+level.showicon+','+level.showdesc+','+level.showtemp;
  1163.         
  1164.         level = objConfigPara.displayLevel['2nd'];
  1165.         strLevels = strLevels + '|'+ level.show+','+level.showicon+','+level.showdesc+','+level.showtemp;
  1166.  
  1167.         level = objConfigPara.displayLevel['3rd'];
  1168.         strLevels = strLevels + '|'+ level.show+','+level.showicon+','+level.showdesc+','+level.showtemp;
  1169.         
  1170.         level = objConfigPara.displayLevel['4th'];
  1171.         strLevels = strLevels + '|'+ level.show+','+level.showicon+','+level.showdesc+','+level.showtemp;
  1172.         
  1173.         level = objConfigPara.displayLevel['5th'];
  1174.         strLevels = strLevels + '|'+ level.show+','+level.showicon+','+level.showdesc+','+level.showtemp;
  1175.         
  1176.         return strLevels; 
  1177.     }
  1178.     
  1179.     function getGraphString()
  1180.     {
  1181.         try{
  1182.         var level = objConfigPara.graphLevel['national'];
  1183.         var strLevels = level.show+','+level.animation;
  1184.  
  1185.         level = objConfigPara.graphLevel['vapor'];
  1186.         strLevels = strLevels + '|'+ level.show+','+level.animation;
  1187.         
  1188.         level = objConfigPara.graphLevel['radar'];
  1189.         strLevels = strLevels + '|'+ level.show+','+level.animation;
  1190.         
  1191.         level = objConfigPara.graphLevel['uv'];
  1192.         strLevels = strLevels + '|'+ level.show+','+level.animation;
  1193.  
  1194.         level = objConfigPara.graphLevel['pop'];
  1195.         strLevels = strLevels + '|'+ level.show+','+level.animation;
  1196.         
  1197.         level = objConfigPara.graphLevel['high'];
  1198.         strLevels = strLevels + '|'+ level.show+','+level.animation;
  1199.         
  1200.         level = objConfigPara.graphLevel['air'];
  1201.         strLevels = strLevels + '|'+ level.show+','+level.animation;
  1202.         
  1203.         level = objConfigPara.graphLevel['alert'];
  1204.         strLevels = strLevels + '|'+ level.show+','+level.animation;
  1205.         }catch(e){alert(e.toString());}
  1206.         
  1207.         return strLevels; 
  1208.     }    
  1209.     
  1210.     function _prepareChromeSettingString()
  1211.     {
  1212.         var strSetting = objConfigPara.tempUnit; 
  1213.  
  1214.         strSetting = strSetting +"&"+ BUILDNO;
  1215.         strSetting = strSetting +"&"+ objConfigPara.defaultLocId;
  1216.  
  1217.         var strId = "";
  1218.         var strName = "";
  1219.         var locNum = objConfigPara.locInfo.length; 
  1220.         for(var i=0;i<locNum;i++)
  1221.         {
  1222.             strName = strName + objConfigPara.locInfo[i].name;
  1223.             strId = strId + objConfigPara.locInfo[i].id;
  1224.             
  1225.             if(i < locNum-1)
  1226.             {
  1227.                 strName = strName + "|";
  1228.                 strId = strId + "|";
  1229.             }
  1230.         }
  1231.         
  1232.         strSetting = strSetting +"&"+ strName;
  1233.         strSetting = strSetting +"&"+ strId;
  1234.         strSetting = strSetting +"&"+ objConfigPara.windUnit;
  1235.         
  1236.         strSetting = strSetting +"&"+ objConfigPara.weatherWidth;
  1237.         strSetting = strSetting +"&"+ objConfigPara.weatherHeight;
  1238.  
  1239.         var strLevels = getLevelString(); 
  1240.         strSetting = strSetting +"&"+ strLevels; 
  1241.         
  1242.         strSetting = strSetting +"&"+ objConfigPara.fadingRatio; 
  1243.         strSetting = strSetting +"&"+ objConfigPara.fadingColor; 
  1244.         strSetting = strSetting +"&"+ objConfigPara.noticeSpan; 
  1245.         strSetting = strSetting +"&"+ objConfigPara.displayMode; 
  1246.         strSetting = strSetting +"&"+ objConfigPara.startNotice; 
  1247.         
  1248.         var strGraphs = getGraphString(); 
  1249.         strSetting = strSetting +"&"+ strGraphs; 
  1250.         strSetting = strSetting +"&"+ objConfigPara.useMiniFrame; 
  1251.         
  1252.         strSetting = strSetting +"&"+ objConfigPara.graphPreviewWidth; 
  1253.         strSetting = strSetting +"&"+ objConfigPara.previewDelay; 
  1254.         
  1255.         return strSetting;     
  1256.     }
  1257.     
  1258.     this.prepareChromeSettingString = function()
  1259.     {
  1260.         return _prepareChromeSettingString(); 
  1261.     }
  1262.     
  1263.     function setEventListener(obj, evt, func, bubble)
  1264.     {
  1265.         try
  1266.         {
  1267.             if(browserType == BROWSER_IE)
  1268.             {
  1269.                 obj.detachEvent('on'+evt, func); 
  1270.                 obj.attachEvent('on'+evt, func, bubble);
  1271.             }
  1272.             else /// if(browserType == BROWSER_FF)
  1273.                 obj.addEventListener(evt, func, bubble);
  1274.         }
  1275.         catch(err)
  1276.         {
  1277.             // loghelper('Error in setEventListener: ' + err + '. Function: ' + func.name, 2); 
  1278.         }            
  1279.     }
  1280.     
  1281.     function loghelper(msg) {
  1282.         if(browserType == BROWSER_FF)
  1283.         {
  1284.             var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
  1285.                 .getService(Components.interfaces.nsIConsoleService);
  1286.                consoleService.logStringMessage('*AniWeather* --- ' + msg);
  1287.         }
  1288.     }
  1289.     
  1290.     this.registerPort = function(port)
  1291.     {
  1292.         curPort = port; 
  1293.     }
  1294.     
  1295.     function positionCanvas()
  1296.     {
  1297.         //. nav-bar, main-menubar, status-bar, toolbar-menubar, "PersonalToolbar"
  1298.         try{
  1299.         
  1300.         var holderId = getCharPref('displayPosition'); 
  1301.         var offset = getIntPref('displayOffset'); 
  1302.         var holder = document.getElementById(holderId);
  1303.         if (!holder)
  1304.             holder = document.getElementById("status-bar");
  1305.         
  1306.         if(!holder)
  1307.             return; 
  1308.  
  1309.         var canvas = document.getElementById("aniweather_canvas");        
  1310.         
  1311.         //. Remove it first if it already exists
  1312.         var children = holder.childNodes;
  1313.         var pos = -1;
  1314.         for (var idx=0; idx<children.length; idx++) 
  1315.         {
  1316.             if (children[idx] == canvas)
  1317.                 pos = idx;
  1318.         }
  1319.         canvas.parentNode.removeChild(canvas);        
  1320.     
  1321.         var newcanvas = null;
  1322.         if (holder.localName == "statusbar") 
  1323.         {
  1324.             if (canvas.localName != "statusbarpanel")
  1325.                 newcanvas = document.createElement("statusbarpanel");
  1326.         } 
  1327.         else 
  1328.         {
  1329.             if (canvas.localName == "statusbarpanel")
  1330.                 newcanvas = document.createElement("hbox");    
  1331.         }
  1332.  
  1333.         if (newcanvas) 
  1334.         {
  1335.             newcanvas.setAttribute("id", "aniweather_canvas");
  1336.             while (canvas.hasChildNodes())
  1337.                 newcanvas.appendChild(canvas.firstChild);      
  1338.         } 
  1339.         else
  1340.             //. Anything wrong here? 
  1341.             newcanvas = canvas;
  1342.         
  1343.         children = holder.childNodes;
  1344.         pos = offset; 
  1345.         if ((children.length == 0) || (pos >= children.length) || (pos < 0))
  1346.           holder.appendChild(newcanvas);
  1347.         else
  1348.           holder.insertBefore(newcanvas, children[pos]);    
  1349.  
  1350.         }catch(e){alert('Error in positioning AniWeather:'+e.toString());}
  1351.     }
  1352.  
  1353.     function smartKeyPress(event)
  1354.     {
  1355.         try{                
  1356.         var event = (!event)? window.event : event; 
  1357.         var keycode ;
  1358.         if(typeof event.keyCode != "undefined") // IE
  1359.             keycode = event.keyCode;
  1360.         else
  1361.             keycode = event.which;
  1362.  
  1363.  
  1364.         if(keycode == 27) // ESC
  1365.         {
  1366.             if(removeWeather(true, true) == 0)
  1367.             {
  1368.                 var doc = getCurDocument();
  1369.                 
  1370.                 aryFlash = doc.getElementsByTagName('object'); 
  1371.                 var len = aryFlash.length; 
  1372.                 for(var i=0;i<len;i++)
  1373.                 {
  1374.                     var objFlash = aryFlash[i];
  1375.                     objFlash.style.visibility = "visible"; 
  1376.                 }
  1377.                 
  1378.                 aryFlash = doc.getElementsByTagName('embed'); 
  1379.                 var len = aryFlash.length; 
  1380.                 for(var i=0;i<len;i++)
  1381.                 {
  1382.                     var objFlash = aryFlash[i];
  1383.                     objFlash.style.visibility = "visible"; 
  1384.                 }    
  1385.             }
  1386.         }
  1387.         }catch(e){alert(e.toString());}
  1388.     }
  1389.     
  1390.     this.MainStart = function(getWeather, getHook)
  1391.     {        
  1392.         var re = initPref(); 
  1393.  
  1394.         if(browserType == BROWSER_FF)
  1395.         {      
  1396.             this.getServerStatus(); 
  1397.             window.addEventListener("load", positionCanvas, false);
  1398.             var appcontent = document.getElementById("appcontent");   // browser
  1399.             if(appcontent)
  1400.             {
  1401.                 setEventListener(appcontent, "DOMContentLoaded", onPageLoad, false);
  1402.             }
  1403.             
  1404.             // this.getWeatherDetails(true, false, null); 
  1405.             _checkWeatherTimer(objConfigPara.startNotice == 1); 
  1406.             
  1407.         }
  1408.         else if(browserType == BROWSER_IE)
  1409.         {
  1410.             onPageLoad(); 
  1411.         }
  1412.         else if(browserType == BROWSER_CHROME)
  1413.         {
  1414.             // setEventListener(document, 'keydown', smartKeyPress, false);
  1415.         
  1416.             if(getHook)
  1417.                 onPageLoad(); 
  1418.             if(getWeather)
  1419.                 this.getWeatherDetails(true, false, null);                        
  1420.         }
  1421.     };    
  1422.     
  1423.     function goToURL(url, show)
  1424.     {
  1425.       var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  1426.                      .getService(Components.interfaces.nsIWindowMediator);
  1427.       var mainWindow = wm.getMostRecentWindow("navigator:browser");
  1428.       browser = mainWindow.getBrowser();
  1429.       browser.selectedTab = browser.addTab(url);
  1430.     }
  1431.     
  1432.     function onAddLoc(event)
  1433.     {
  1434.         eventDoc = getDocumentByEvent(event); 
  1435.         var name = eventDoc.getElementById('inputLocation').value;
  1436.         eventDoc.getElementById('loadSearching').style.display = "block";
  1437.         eventDoc.getElementById('divSelect').style.display = "none";
  1438.  
  1439.         if(browserType == BROWSER_FF)
  1440.         {
  1441.             launchLocSearch(name); 
  1442.         }
  1443.         else if(browserType == BROWSER_CHROME)
  1444.         {
  1445.             if(curPort)
  1446.             {
  1447.                 curPort.postMessage({'purpose':'locid', 'name':name}); 
  1448.             }
  1449.         }                
  1450.     }
  1451.  
  1452.     this.searchLocalId = function(name)
  1453.     {
  1454.         launchLocSearch(name); 
  1455.     }
  1456.     
  1457.     function serverStatusCallback()
  1458.     {
  1459.         if (xmlServer && xmlServer.readyState==4)
  1460.         {
  1461.             var status = -1; 
  1462.             if(xmlServer.status==200)
  1463.             {
  1464.                 var data = xmlServer.responseText; 
  1465.                 var aryValues = data.split(','); 
  1466.                 if(aryValues.length == 2 && aryValues[0] == '0')
  1467.                     status = 0; 
  1468.             }    
  1469.         
  1470.             if(status == 0 )
  1471.             {
  1472.                 aniweatherHostName = "www.aniweather.com";
  1473.                 weatherSiteBase = 'http://www.aniweather.com/'; 
  1474.             }
  1475.             else
  1476.             {
  1477.                 aniweatherHostName = "aniweather.s3.amazonaws.com";
  1478.                 weatherSiteBase = 'http://aniweather.s3.amazonaws.com/www/'; 
  1479.             }                
  1480.         }        
  1481.     }
  1482.     
  1483.     this.getServerType = function()
  1484.     {
  1485.         if(aniweatherHostName == "www.aniweather.com")
  1486.             return 0; 
  1487.         else 
  1488.             return 1; 
  1489.     }
  1490.     
  1491.     this.setServerType = function(type)
  1492.     {
  1493.         if(type == 0)
  1494.         {
  1495.             aniweatherHostName = "www.aniweather.com";
  1496.             weatherSiteBase = 'http://www.aniweather.com/'; 
  1497.         }
  1498.         else
  1499.         {
  1500.             aniweatherHostName = "aniweather.s3.amazonaws.com";
  1501.             weatherSiteBase = 'http://aniweather.s3.amazonaws.com/www/'; 
  1502.         }    
  1503.     }    
  1504.     
  1505.     this.getServerStatus = function()
  1506.     {
  1507.         xmlServer=null;
  1508.         
  1509.         var url = "http://www.aniweather.com/status.html"; 
  1510.         if (window.XMLHttpRequest)
  1511.         {
  1512.             // code for all new browsers
  1513.             xmlServer=new XMLHttpRequest();
  1514.         }
  1515.         else if (window.ActiveXObject)
  1516.         {
  1517.             // code for IE5 and IE6
  1518.             xmlServer=new ActiveXObject("Microsoft.XMLHTTP");
  1519.         }
  1520.         
  1521.         if (xmlServer!=null)
  1522.         {
  1523.             xmlServer.onreadystatechange= serverStatusCallback;
  1524.             xmlServer.open("GET",url,true);
  1525.             xmlServer.send(null);
  1526.         }
  1527.     }
  1528.     
  1529.     function launchLocSearch(name)
  1530.     {
  1531.         xmlhttp=null;
  1532.         
  1533.         // var url = 'http://www.google.com/ig/api?weather='+objConfigPara.locationInfo.city;
  1534.         var url = locSearchBase+""+name; 
  1535.         if (window.XMLHttpRequest)
  1536.         {
  1537.             // code for all new browsers
  1538.             xmlhttp=new XMLHttpRequest();
  1539.         }
  1540.         else if (window.ActiveXObject)
  1541.         {
  1542.             // code for IE5 and IE6
  1543.             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  1544.         }
  1545.         
  1546.         if (xmlhttp!=null)
  1547.         {
  1548.             xmlhttp.onreadystatechange=LocInfoReady;
  1549.             xmlhttp.open("GET",url,true);
  1550.             xmlhttp.send(null);
  1551.         }
  1552.         else
  1553.         {
  1554.             // alert("Error in loading the loc info.");
  1555.         }
  1556.     }
  1557.  
  1558.     function LocInfoReady()
  1559.     {
  1560.         if (xmlhttp && xmlhttp.readyState==4)
  1561.         {
  1562.             // 4 = "loaded"
  1563.             if (xmlhttp.status==200)
  1564.             {
  1565.                 // 200 = OK
  1566.                 // ...our code here...
  1567.                 parseLocInfo(xmlhttp.responseText); 
  1568.             }
  1569.             else
  1570.             {
  1571.                 // alert("Error in loading the weather info.");
  1572.             }
  1573.         }        
  1574.     }
  1575.  
  1576.     this.localIdReady = function(data)
  1577.     {
  1578.         var aryIds = []; 
  1579.         if(data.length > 0)
  1580.             aryIds = data.split('|'); 
  1581.         var len = aryIds.length;
  1582.         
  1583.         aryLocInfo = [];
  1584.         for(var i=0;i<len;i++)
  1585.         {
  1586.             var aryVal = aryIds[i].split('&'); 
  1587.             var objLoc = new AniWeatherObj.LocSearchInfo(); 
  1588.             objLoc.name = aryVal[0];
  1589.             objLoc.id = aryVal[1];
  1590.             aryLocInfo.push(objLoc);             
  1591.         }
  1592.         
  1593.         
  1594.         updateLocList(); 
  1595.     }
  1596.     
  1597.     function parseLocInfo(data)
  1598.     {
  1599.         aryLocInfo = [];
  1600.         var strLocId = "";
  1601.         try{
  1602.             if(data.length)
  1603.             {    
  1604.                 var xmlDoc = parseXML(data); 
  1605.         
  1606.                 //. Head info
  1607.                 var objElem = xmlDoc.getElementsByTagName("search")[0];
  1608.                 var aryNodes = objElem.childNodes;
  1609.                 var len = aryNodes.length; 
  1610.  
  1611.                 // <loc id="USNY0996" type="1">New York, NY</loc>
  1612.                 for(var i=0;i<len;i++)
  1613.                 {
  1614.                     var objData = aryNodes[i]; 
  1615.                     if(objData.nodeName.toLowerCase() == "loc")
  1616.                     {
  1617.                         var objLoc = new AniWeatherObj.LocSearchInfo(); 
  1618.                         objLoc.name = objData.childNodes[0].nodeValue;
  1619.                         objLoc.id = objData.attributes.getNamedItem("id").value;
  1620.                         objLoc.type = objData.attributes.getNamedItem("id").value;
  1621.                         aryLocInfo.push(objLoc); 
  1622.                         
  1623.                         if(strLocId.length > 0)
  1624.                             strLocId = strLocId + "|"; 
  1625.                         strLocId = strLocId + objLoc.name +"&" +objLoc.id ;                        
  1626.                     }
  1627.                 }
  1628.             }
  1629.         }catch(e){
  1630.             // alert(e.toString());
  1631.             var strLocId = "";
  1632.             var posStart; 
  1633.             var posEnd;
  1634.             var startToken = 'id="';
  1635.             var tokenLen = startToken.length; 
  1636.             var strId = "";
  1637.             var strName = "";
  1638.             var idx = 0; 
  1639.             while(true)
  1640.             {
  1641.                 // <loc id="USNY0996" type="1">New York, NY</loc>
  1642.                 posStart = data.indexOf(startToken); 
  1643.                 if(posStart)
  1644.                 {
  1645.                     data = data.substr(posStart+tokenLen); 
  1646.                     
  1647.                     posEnd = data.indexOf('"'); 
  1648.                     if(posEnd > 0)
  1649.                     {
  1650.                         strId = data.substr(0, posEnd); 
  1651.                         data = data.substr(posEnd); 
  1652.                     }
  1653.                     else
  1654.                         //. Broken?
  1655.                         break;
  1656.                     
  1657.                     posStart = data.indexOf('>');
  1658.                     posEnd = data.indexOf('<'); 
  1659.  
  1660.                     if(posStart > 0 && posEnd > 0)
  1661.                     {
  1662.  
  1663.                         strName = data.substr(posStart+1, posEnd-posStart-1); 
  1664.                         data = data.substr(posEnd); 
  1665.                     }
  1666.                     else
  1667.                         //. Broken?
  1668.                         break;
  1669.  
  1670.                     if(idx > 0)
  1671.                         strLocId = strLocId + "|"; 
  1672.                         
  1673.                     strLocId = strLocId + strName +"&" +strId;
  1674.                     idx++;
  1675.                 }                
  1676.                 else
  1677.                     break;
  1678.             }
  1679.         }
  1680.         
  1681.         if(browserType == BROWSER_FF)
  1682.         {
  1683.             updateLocList();        
  1684.         }
  1685.         else if(browserType == BROWSER_CHROME)
  1686.         {
  1687.             var objLocId = document.getElementById('hiddenLocId'); 
  1688.             if(objLocId)
  1689.                 objLocId.value = strLocId; 
  1690.  
  1691.             var objReady = document.getElementById('chkLocIdReady'); 
  1692.             if(objReady)
  1693.             {
  1694.                 objReady.checked = true; 
  1695.                 objReady.onclick();
  1696.             }
  1697.         }        
  1698.     }
  1699.  
  1700.     function updateLocList()
  1701.     {
  1702.         try    {
  1703.             var divLoc = eventDoc.getElementById('divLocations'); 
  1704.             divLoc.innerHTML = "";
  1705.             
  1706.             // var ulLoc = eventDoc.getElementById('ulAniweatherLocList'); 
  1707.             // if(ulLoc)
  1708.             //     divLoc.removeChild(ulLoc); 
  1709.             // ulLoc = document.createElement("ul");
  1710.             // ulLoc.id = 'ulAniweatherLocList';
  1711.             
  1712.             eventDoc.getElementById('loadSearching').style.display = "none";
  1713.             if(aryLocInfo.length > 0)
  1714.             {
  1715.                 var strContent = "<ul id='ulAniweatherLocList'>";
  1716.                 var len = aryLocInfo.length;
  1717.                 for(var i=0;i<len;i++)
  1718.                 {
  1719.                     var objLoc = aryLocInfo[i];
  1720.                     strContent = strContent + '<li><a onclick="chooseLocation(event);" id="'+objLoc.id+'" href="javascript:; ">'+objLoc.name+'</a></li>'; 
  1721.                 }
  1722.                 strContent = strContent + "</ul>"; 
  1723.                 
  1724.                 // ulLoc.innerHTML = strContent; 
  1725.                 // divLoc.appendChild(ulLoc); 
  1726.                 divLoc.innerHTML = strContent; 
  1727.                 
  1728.                 eventDoc.getElementById('divSelect').style.display = "block";    
  1729.             }
  1730.             else
  1731.             {
  1732.                 alert(getLocaleString('alert.no.locations.found')); 
  1733.             }                
  1734.             
  1735.         }catch(err){}                
  1736.     }    
  1737.     
  1738.     function _initOptionSettings(doc)
  1739.     {
  1740.         try{
  1741.             doc.getElementById('rdoF').checked = (objConfigPara.tempUnit == 0); 
  1742.             doc.getElementById('rdoC').checked = (objConfigPara.tempUnit == 1); 
  1743.             doc.getElementById('rdoM').checked = (objConfigPara.windUnit == 0); 
  1744.             doc.getElementById('rdoK').checked = (objConfigPara.windUnit == 1); 
  1745.             doc.getElementById('divSelect').style.display = "none";
  1746.             doc.getElementById('loadSearching').style.display = "none";
  1747.             
  1748.             doc.getElementById('defaultLocId').value = objConfigPara.defaultLocId;
  1749.             doc.getElementById('defaultLoc').innerHTML = objConfigPara.locInfo[objConfigPara.defaultLocId].name;
  1750.             var objLocList = doc.getElementById('lstLocations');
  1751.             var len = objConfigPara.locInfo.length;
  1752.             for (var i=0;i<len;i++) {
  1753.                 objLocList.add(new Option(objConfigPara.locInfo[i].name, objConfigPara.locInfo[i].id), null);  
  1754.             }            
  1755.             
  1756.             doc.getElementById('lstAnimationSize').value = objConfigPara.weatherWidth; 
  1757.             doc.getElementById('lstFadingRatio').value = objConfigPara.fadingRatio; 
  1758.             doc.getElementById('lstFadingColor').value = objConfigPara.fadingColor; 
  1759.             doc.getElementById('lstNoticeSpan').value = objConfigPara.noticeSpan; 
  1760.             doc.getElementById('lstDisplayMode').value = objConfigPara.displayMode; 
  1761.             doc.getElementById('chkStartNotice').checked = (objConfigPara.startNotice == 1) ? true:false; 
  1762.             doc.getElementById('lstDisplayPosition').value = objConfigPara.displayPosition; 
  1763.             doc.getElementById('inputDisplayOffset').value = objConfigPara.displayOffset; 
  1764.             doc.getElementById('lstGraphicPreviewSize').value = objConfigPara.graphPreviewWidth; 
  1765.             doc.getElementById('lstPreviewDelay').value = objConfigPara.previewDelay; 
  1766.             
  1767.             var obj = doc.getElementById('chkUseMiniFrame');
  1768.             if(obj) obj.checked = (objConfigPara.useMiniFrame == 1) ? true:false; 
  1769.             
  1770.             var level = objConfigPara.displayLevel['current'];
  1771.             doc.getElementById('chkCurrent').checked = (level.show == 1) ? true : false;             
  1772.             doc.getElementById('chkCurrentIcon').checked = (level.showicon == 1) ? true : false;             
  1773.             doc.getElementById('chkCurrentDesc').checked = (level.showdesc == 1) ? true : false;             
  1774.             doc.getElementById('chkCurrentTemp').checked = (level.showtemp == 1) ? true : false;             
  1775.             
  1776.             level = objConfigPara.displayLevel['today'];
  1777.             doc.getElementById('chkToday').checked = (level.show == 1) ? true : false;             
  1778.             doc.getElementById('chkTodayIcon').checked = (level.showicon == 1) ? true : false;             
  1779.             doc.getElementById('chkTodayDesc').checked = (level.showdesc == 1) ? true : false;             
  1780.             doc.getElementById('chkTodayTemp').checked = (level.showtemp == 1) ? true : false;             
  1781.             
  1782.             level = objConfigPara.displayLevel['2nd'];
  1783.             doc.getElementById('chk2nd').checked = (level.show == 1) ? true : false;             
  1784.             doc.getElementById('chk2ndIcon').checked = (level.showicon == 1) ? true : false;             
  1785.             doc.getElementById('chk2ndDesc').checked = (level.showdesc == 1) ? true : false;             
  1786.             doc.getElementById('chk2ndTemp').checked = (level.showtemp == 1) ? true : false;             
  1787.  
  1788.             level = objConfigPara.displayLevel['3rd'];
  1789.             doc.getElementById('chk3rd').checked = (level.show == 1) ? true : false;             
  1790.             doc.getElementById('chk3rdIcon').checked = (level.showicon == 1) ? true : false;             
  1791.             doc.getElementById('chk3rdDesc').checked = (level.showdesc == 1) ? true : false;             
  1792.             doc.getElementById('chk3rdTemp').checked = (level.showtemp == 1) ? true : false;             
  1793.  
  1794.             level = objConfigPara.displayLevel['4th'];
  1795.             doc.getElementById('chk4th').checked = (level.show == 1) ? true : false;             
  1796.             doc.getElementById('chk4thIcon').checked = (level.showicon == 1) ? true : false;             
  1797.             doc.getElementById('chk4thDesc').checked = (level.showdesc == 1) ? true : false;             
  1798.             doc.getElementById('chk4thTemp').checked = (level.showtemp == 1) ? true : false;             
  1799.     
  1800.             level = objConfigPara.displayLevel['5th'];
  1801.             doc.getElementById('chk5th').checked = (level.show == 1) ? true : false;             
  1802.             doc.getElementById('chk5thIcon').checked = (level.showicon == 1) ? true : false;             
  1803.             doc.getElementById('chk5thDesc').checked = (level.showdesc == 1) ? true : false;             
  1804.             doc.getElementById('chk5thTemp').checked = (level.showtemp == 1) ? true : false;             
  1805.     
  1806.             var graph = objConfigPara.graphLevel['national'];
  1807.             doc.getElementById('chkNational').checked = (graph.show == 1) ? true : false;             
  1808.             doc.getElementById('chkNationalAnimation').checked = (graph.animation == 1) ? true : false;             
  1809.  
  1810.             graph = objConfigPara.graphLevel['vapor'];
  1811.             doc.getElementById('chkVapor').checked = (graph.show == 1) ? true : false;             
  1812.             doc.getElementById('chkVaporAnimation').checked = (graph.animation == 1) ? true : false;             
  1813.             
  1814.             graph = objConfigPara.graphLevel['radar'];
  1815.             doc.getElementById('chkRadar').checked = (graph.show == 1) ? true : false;             
  1816.             doc.getElementById('chkRadarAnimation').checked = (graph.animation == 1) ? true : false;             
  1817.  
  1818.             graph = objConfigPara.graphLevel['uv'];
  1819.             doc.getElementById('chkUV').checked = (graph.show == 1) ? true : false;             
  1820.             doc.getElementById('chkUVAnimation').checked = (graph.animation == 1) ? true : false;             
  1821.  
  1822.             graph = objConfigPara.graphLevel['pop'];
  1823.             doc.getElementById('chkPop').checked = (graph.show == 1) ? true : false;             
  1824.             doc.getElementById('chkPopAnimation').checked = (graph.animation == 1) ? true : false;             
  1825.  
  1826.             graph = objConfigPara.graphLevel['high'];
  1827.             doc.getElementById('chkHigh').checked = (graph.show == 1) ? true : false;             
  1828.             doc.getElementById('chkHighAnimation').checked = (graph.animation == 1) ? true : false;             
  1829.  
  1830.             graph = objConfigPara.graphLevel['air'];
  1831.             doc.getElementById('chkAir').checked = (graph.show == 1) ? true : false;             
  1832.             doc.getElementById('chkAirAnimation').checked = (graph.animation == 1) ? true : false;             
  1833.  
  1834.             graph = objConfigPara.graphLevel['alert'];
  1835.             doc.getElementById('chkAlert').checked = (graph.show == 1) ? true : false;             
  1836.             doc.getElementById('chkAlertAnimation').checked = (graph.animation == 1) ? true : false;             
  1837.             
  1838.             var btnAdd = doc.getElementById('btnAddNew');
  1839.             setEventListener(btnAdd, 'click', onAddLoc, false); 
  1840.             
  1841.             var frmAddLoc = doc.getElementById('frmAddLoc');
  1842.             setEventListener(frmAddLoc, 'submit', onAddLoc, false); 
  1843.             
  1844.             var btnOK = doc.getElementById('btnOK');
  1845.             setEventListener(btnOK, 'click', onApplySetting, false); 
  1846.             
  1847.         }catch(e){}
  1848.     }
  1849.     
  1850.     function validateSetting(doc)
  1851.     {
  1852.         var objLocList = doc.getElementById('lstLocations'); 
  1853.         if(objLocList.options.length == 0)
  1854.         {
  1855.             alert(getLocaleString('alert.need.one.location')); 
  1856.             return false; 
  1857.         }
  1858.         
  1859.         if(!doc.getElementById('chkCurrent').checked && 
  1860.            !doc.getElementById('chkToday').checked   && 
  1861.            !doc.getElementById('chk2nd').checked       &&
  1862.            !doc.getElementById('chk3rd').checked      &&
  1863.            !doc.getElementById('chk4th').checked      &&
  1864.            !doc.getElementById('chk5th').checked)
  1865.         {
  1866.             alert(getLocaleString('alert.need.one.condition')); 
  1867.             return false;         
  1868.         }
  1869.     }
  1870.     
  1871.     function getStatusDisplay(doc, day)
  1872.     {
  1873.         var objLevel = new AniWeatherObj.DisplayLevel(
  1874.             doc.getElementById('chk'+day).checked ? 1:0,
  1875.             doc.getElementById('chk'+day+'Icon').checked ? 1:0,
  1876.             doc.getElementById('chk'+day+'Desc').checked ? 1:0,
  1877.             doc.getElementById('chk'+day+'Temp').checked ? 1:0); 
  1878.  
  1879.         return objLevel; 
  1880.     }
  1881.     
  1882.     function getGraphDisplay(doc, name)
  1883.     {
  1884.         var objGraph = new AniWeatherObj.GraphLevel(
  1885.             doc.getElementById('chk'+name).checked ? 1:0, defaultGraphWidth, defaultGraphHeight, 
  1886.             doc.getElementById('chk'+name+'Animation').checked ? 1:0); 
  1887.  
  1888.         return objGraph; 
  1889.     }    
  1890.     
  1891.     function onApplySetting(event)
  1892.     {
  1893.         event = event ? event : window.event; 
  1894.         var doc = getDocumentByEvent(event); 
  1895.         if(validateSetting(doc) == false)
  1896.             return false; 
  1897.             
  1898.         try{
  1899.         
  1900.             var objTempConfig = new AniWeatherObj.ConfigPara();         
  1901.             objTempConfig.tempUnit = doc.getElementById('rdoC').checked ? 1 : 0; 
  1902.             objTempConfig.windUnit = doc.getElementById('rdoK').checked ? 1 : 0; 
  1903.             objTempConfig.defaultLocId = parseInt(doc.getElementById('defaultLocId').value); 
  1904.             
  1905.             objTempConfig.locInfo = [];
  1906.             
  1907.             var objLocList = doc.getElementById('lstLocations'); 
  1908.             var len = objLocList.options.length; 
  1909.             
  1910.             var addedNum = 0; 
  1911.             for(var i=0;i<len;i++)
  1912.             {
  1913.                 objTempConfig.locInfo.push({'name':objLocList.options[i].text, 'id':objLocList.options[i].value}); 
  1914.                 addedNum++;
  1915.             }
  1916.             
  1917.             objTempConfig.weatherWidth = parseInt(doc.getElementById('lstAnimationSize').value); 
  1918.         
  1919.             objTempConfig.fadingRatio  = parseInt(doc.getElementById('lstFadingRatio').value); 
  1920.             objTempConfig.fadingColor  = doc.getElementById('lstFadingColor').value; 
  1921.             objTempConfig.noticeSpan   = parseInt(doc.getElementById('lstNoticeSpan').value);
  1922.             objTempConfig.displayMode   = parseInt(doc.getElementById('lstDisplayMode').value);
  1923.             objTempConfig.displayPosition = doc.getElementById('lstDisplayPosition').value;
  1924.             objTempConfig.startNotice   = doc.getElementById('chkStartNotice').checked ? 1 : 0;
  1925.             objTempConfig.graphPreviewWidth = parseInt(doc.getElementById('lstGraphicPreviewSize').value);
  1926.             objTempConfig.previewDelay = parseInt(doc.getElementById('lstPreviewDelay').value);
  1927.             
  1928.             var value = parseInt(doc.getElementById('inputDisplayOffset').value);
  1929.             objTempConfig.displayOffset  = isNaN(value) ? -1 : value;
  1930.                                    
  1931.             var obj = doc.getElementById('chkUseMiniFrame');
  1932.             if(obj) objTempConfig.useMiniFrame = obj.checked ? 1:0; 
  1933.                                    
  1934.             objTempConfig.displayLevel['current'] = getStatusDisplay(doc, "Current");             
  1935.             objTempConfig.displayLevel['today'] = getStatusDisplay(doc, "Today");             
  1936.             objTempConfig.displayLevel['2nd'] = getStatusDisplay(doc, "2nd");             
  1937.             objTempConfig.displayLevel['3rd'] = getStatusDisplay(doc, "3rd");             
  1938.             objTempConfig.displayLevel['4th'] = getStatusDisplay(doc, "4th");             
  1939.             objTempConfig.displayLevel['5th'] = getStatusDisplay(doc, "5th");             
  1940.  
  1941.             objTempConfig.graphLevel['national'] = getGraphDisplay(doc, "National");             
  1942.             objTempConfig.graphLevel['vapor'] = getGraphDisplay(doc, "Vapor");             
  1943.             objTempConfig.graphLevel['radar'] = getGraphDisplay(doc, "Radar");             
  1944.             objTempConfig.graphLevel['uv'] = getGraphDisplay(doc, "UV");             
  1945.             objTempConfig.graphLevel['pop'] = getGraphDisplay(doc, "Pop");             
  1946.             objTempConfig.graphLevel['high'] = getGraphDisplay(doc, "High");             
  1947.             objTempConfig.graphLevel['air'] = getGraphDisplay(doc, "Air");             
  1948.             objTempConfig.graphLevel['alert'] = getGraphDisplay(doc, "Alert");             
  1949.  
  1950.             // Validate again
  1951.             if(objTempConfig.defaultLocId < 0 || objTempConfig.defaultLocId >=  objTempConfig.locInfo.length)
  1952.                 objTempConfig.defaultLocId = 0; 
  1953.             
  1954.             objConfigPara.copyConfig(objTempConfig);
  1955.             if(savePref())
  1956.             {
  1957.                 if(browserType == BROWSER_FF)
  1958.                     _getWeatherDetails(false, false, null);                
  1959.                 alert(getLocaleString('alert.applying.setting')); 
  1960.             }
  1961.         }catch(e){}
  1962.     }    
  1963.     
  1964.     function onPageLoad(event) 
  1965.     {
  1966.         try{
  1967.             // alert(location);
  1968.             var myLocalStorage = localStorage;
  1969.         }catch(e){}
  1970.             
  1971.         try{
  1972.             if(browserType == BROWSER_FF)
  1973.             {
  1974.                 eventDoc = getObjectByEvent(event); // doc is document that triggered "onload" event            
  1975.             }
  1976.             
  1977.             else
  1978.                 eventDoc = document; 
  1979.             
  1980.             var hostName = eventDoc.defaultView.location.hostname.toLowerCase();
  1981.             var strURL = eventDoc.URL.toLowerCase();
  1982.             var pos = strURL.indexOf(settingPageName); 
  1983.             
  1984.             if(pos > 0 && aniweatherHostName == hostName) //. TODO: refine the checking
  1985.             {
  1986.                 if(browserType == BROWSER_CHROME)
  1987.                 {
  1988.                     //. Working around Chrome's racing bug. 
  1989.                     setTimeout(function(){
  1990.                         if(curPort)
  1991.                             curPort.postMessage({'purpose':'getsetting'});                     
  1992.                             }, 300); 
  1993.                     
  1994.                 }
  1995.                 else            
  1996.                     _initOptionSettings(eventDoc); 
  1997.             }
  1998.         }catch(e){}        
  1999.     }
  2000.     
  2001.     this.onGetChromeSetting = function(value)
  2002.     {
  2003.         objConfigPara.parseChromeSetting(value); 
  2004.         
  2005.         _initOptionSettings(eventDoc); 
  2006.     }
  2007.     
  2008.      function getIntPref(name)
  2009.       {
  2010.         if(browserType == BROWSER_FF)
  2011.         {
  2012.             // prefManager = Components.classes["@mozilla.org/preferences-service;1"]
  2013.             //     .getService(Components.interfaces.nsIPrefService).getBranch("extensions.aniweather.");
  2014.             // var nValue = prefManager.getIntPref(name);
  2015.             // return nValue;
  2016.         
  2017.             var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
  2018.             return prefManager.getIntPref('extensions.aniweather.'+name);              
  2019.             
  2020.         }
  2021.         else if(browserType == BROWSER_CHROME)
  2022.         {
  2023.         }
  2024.         else
  2025.             return -1;
  2026.       }
  2027.       
  2028.       function setIntPref(name, value)
  2029.       {
  2030.         if(browserType == BROWSER_FF)
  2031.         {
  2032.             /*
  2033.             /// The following masked codes would trigger compatibility issue w/ Google Reader Watcher. 
  2034.             /// Not sure why, but the modify codes are OK. 
  2035.                 prefManager = Components.classes["@mozilla.org/preferences-service;1"]
  2036.                         .getService(Components.interfaces.nsIPrefService).getBranch("extensions.aniweather.");
  2037.                 var nValue = prefManager.setIntPref(name, value);
  2038.               
  2039.                 return nValue;
  2040.             */
  2041.              var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
  2042.              prefManager.setIntPref('extensions.aniweather.'+name, value);
  2043.  
  2044.         }
  2045.       }         
  2046.       
  2047.     function checkPrefPresent(name)
  2048.     {
  2049.         if(browserType == BROWSER_FF)
  2050.         {
  2051.             // prefManager = Components.classes["@mozilla.org/preferences-service;1"]
  2052.             //     .getService(Components.interfaces.nsIPrefService).getBranch("extensions.aniweather.");
  2053.             // var strValue = prefManager.getCharPref(name);
  2054.             // return strValue;
  2055.             
  2056.             var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
  2057.             return prefManager.prefHasUserValue('extensions.aniweather.'+name);              
  2058.         }
  2059.         else
  2060.             return false;    
  2061.     }
  2062.     
  2063.       function getCharPref(name)
  2064.       {
  2065.         if(browserType == BROWSER_FF)
  2066.         {
  2067.             // prefManager = Components.classes["@mozilla.org/preferences-service;1"]
  2068.             //     .getService(Components.interfaces.nsIPrefService).getBranch("extensions.aniweather.");
  2069.             // var strValue = prefManager.getCharPref(name);
  2070.             // return strValue;
  2071.             
  2072.             var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
  2073.             return prefManager.getCharPref('extensions.aniweather.'+name);              
  2074.             
  2075.         }
  2076.         else
  2077.             return "";
  2078.       }
  2079.       
  2080.       function setCharPref(name, value)
  2081.       {
  2082.         if(browserType == BROWSER_FF)
  2083.         {
  2084.             // prefManager = Components.classes["@mozilla.org/preferences-service;1"]
  2085.             //     .getService(Components.interfaces.nsIPrefService).getBranch("extensions.aniweather.");
  2086.             // var strValue = prefManager.setCharPref(name, value);
  2087.             // return strValue;
  2088.             var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
  2089.             prefManager.setCharPref('extensions.aniweather.'+name, value);
  2090.             
  2091.         }      
  2092.       } 
  2093.     
  2094.      function getComplexPref(name)
  2095.       {
  2096.         if(browserType == BROWSER_FF)
  2097.         {
  2098.             var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
  2099.             return prefManager.getComplexValue('extensions.aniweather.'+name,
  2100.                     Components.interfaces.nsISupportsString).data;      
  2101.         }
  2102.         else
  2103.             return "";
  2104.       }
  2105.  
  2106.  
  2107.       function setComplexPref(name, value)
  2108.       {
  2109.         if(browserType == BROWSER_FF)
  2110.         {
  2111.             var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
  2112.             
  2113.             var str = Components.classes["@mozilla.org/supports-string;1"]
  2114.                   .createInstance(Components.interfaces.nsISupportsString);
  2115.             str.data = value;
  2116.             
  2117.             prefManager.setComplexValue('extensions.aniweather.'+name, Components.interfaces.nsISupportsString, str); 
  2118.         }      
  2119.       }     
  2120.     
  2121.     this.menuSearch = function(event)
  2122.     {
  2123.         obj = getObjectByEvent(event); 
  2124.         var locId = obj.value; 
  2125.         
  2126.         this.getWeatherDetails(false, true, null, locId)
  2127.     }
  2128.         
  2129.     this.tenDaysReport = function(event)
  2130.     {
  2131.         var obj = getObjectByEvent(event); 
  2132.         var locId = obj.value; 
  2133.         
  2134.         var len = objConfigPara.locInfo.length; 
  2135.         for(i=0;i<len;i++)
  2136.         {
  2137.             var objLoc = objConfigPara.locInfo[i];
  2138.             if(objLoc.id == locId)
  2139.             {
  2140.                 var name = objLoc.name; 
  2141.                 var url = weatherSiteBase + tenDaysReportURL + "?id=" + locId + "&name=" + name + "&phase=" + objWeatherInfo.currentInfo.moonicon;
  2142.                 goToURL(url, true); 
  2143.                 
  2144.                 break;
  2145.             }
  2146.         }        
  2147.     }
  2148.     
  2149.     this.hourlyReport = function(event)
  2150.     {
  2151.         var obj = getObjectByEvent(event); 
  2152.         var locId = obj.value; 
  2153.         var len = objConfigPara.locInfo.length; 
  2154.         for(i=0;i<len;i++)
  2155.         {
  2156.             var objLoc = objConfigPara.locInfo[i];
  2157.             if(objLoc.id == locId)
  2158.             {
  2159.                 var name = objLoc.name; 
  2160.                 var url = weatherSiteBase + hourlyReportURL + "?id=" + locId + "&name=" + name + "&phase=" + objWeatherInfo.currentInfo.moonicon;
  2161.                 goToURL(url, true); 
  2162.                 
  2163.                 break;
  2164.             }
  2165.         }
  2166.     }    
  2167.     
  2168.     this.updateLocationPopup = function(event)
  2169.     {
  2170.         var popup = getObjectByEvent(event); 
  2171.         // var popup = document.getElementById("aniweather-status-location-popup");
  2172.         
  2173.         // aniweather-status-location-popup
  2174.         // aniweather-status-hourly-popup
  2175.         // aniweather-status-10day-popup
  2176.         
  2177.         if(!popup)
  2178.             return; 
  2179.             
  2180.         //. Clear current set
  2181.         while (popup.firstChild) {
  2182.           popup.removeChild(popup.firstChild);
  2183.         }
  2184.  
  2185.         var len = objConfigPara.locInfo.length; 
  2186.  
  2187.         for(i=0;i<len;i++)
  2188.         {
  2189.             var objLoc = objConfigPara.locInfo[i];
  2190.             var objItem = document.createElement("menuitem"); 
  2191.             objItem.setAttribute("label", objLoc.name);
  2192.  
  2193.             objItem.setAttribute("value", objLoc.id); 
  2194.             objItem.setAttribute("id", objLoc.id); 
  2195.             if(i==objConfigPara.defaultLocId)
  2196.             {
  2197.                 objItem.setAttribute("type", "checkbox"); 
  2198.                 objItem.setAttribute("checked", "true"); 
  2199.             }
  2200.             // objItem.setAttribute("class", "menuitem-iconic"); 
  2201.             // objItem.setAttribute("image", aryChannels[i].logoimg);
  2202.             
  2203.             if(popup.id == "aniweather-status-location-popup")
  2204.                 objItem.setAttribute("oncommand", "AniWeatherObj.menuSearch(event);");
  2205.             else if(popup.id == "aniweather-status-10day-popup")
  2206.                 objItem.setAttribute("oncommand", "AniWeatherObj.tenDaysReport(event);");
  2207.             else if (popup.id == "aniweather-status-hourly-popup")
  2208.                 objItem.setAttribute("oncommand", "AniWeatherObj.hourlyReport(event);");
  2209.             popup.appendChild(objItem); 
  2210.         }
  2211.     }
  2212.     
  2213.     function getDateInfo(strDate)
  2214.     {
  2215.         //. 
  2216.         // String format: 5/30/09 1:22 PM Local Time
  2217.         var objDate=new Date();
  2218.         var yearPrefix = Math.floor(objDate.getFullYear()/100); 
  2219.  
  2220.         aryDates = strDate.split('/'); 
  2221.         var month = parseInt(aryDates[0].trim()) - 1; 
  2222.         var monthdate = parseInt(aryDates[1].trim()); 
  2223.         
  2224.         var strYear = aryDates[2].trim();
  2225.         var pos = strYear.indexOf(' '); 
  2226.         if(pos)
  2227.             strYear = strYear.substr(0, pos); 
  2228.         
  2229.         if(strYear.length == 2)
  2230.             strYear = yearPrefix +""+ strYear ;
  2231.             
  2232.         var year = parseInt(strYear); 
  2233.         
  2234.         objDate.setFullYear(year, month, monthdate);
  2235.     
  2236.         //. Set to the noon of that day 
  2237.         objDate.setTime(objDate.getTime());     
  2238.         
  2239.         //. WEEKDAYS
  2240.         month = objDate.getMonth();
  2241.         var strDate = objDate.getDate();
  2242.         if(strDate < 10)
  2243.             strDate = "0"+strDate;
  2244.         monthdate = MONTHS[objDate.getMonth()]+'/'+strDate; 
  2245.         
  2246.         var day = objDate.getDay();
  2247.         var curtime = objDate.getTime(); 
  2248.         objWeatherInfo.day = WEEKDAYS[day];
  2249.         
  2250.         objWeatherInfo.days = objWeatherInfo.day+","+WEEKDAYS[day+1]+","+WEEKDAYS[day+2]+","+WEEKDAYS[day+3]+","+WEEKDAYS[day+4];
  2251.         
  2252.         objWeatherInfo.dates = monthdate;
  2253.         var oneday = 24*3600000; // 1day = 24hr * 3600 sec/hr * 1000millisec/sec
  2254.         for(var i=0;i<4;i++)
  2255.         {
  2256.             curtime += oneday;
  2257.             objDate.setTime(curtime); 
  2258.             var strDate = objDate.getDate();
  2259.             if(strDate < 10)
  2260.                 strDate = "0"+strDate;
  2261.             objWeatherInfo.dates = objWeatherInfo.dates +","+MONTHS[objDate.getMonth()]+'/'+strDate;            
  2262.             
  2263.             objWeatherInfo.dailyInfo[i+1].weekday = RAWWEEKDAYS[day+i+1];
  2264.         }
  2265.         objWeatherInfo.dailyInfo[0].weekday = RAWWEEKDAYS[day];
  2266.     }
  2267.     
  2268.     this.getWeatherDetails = function(force, display, event, locId)
  2269.     {
  2270.         _getWeatherDetails(force, display, event, locId);
  2271.     }
  2272.     
  2273.     function checkStoredWeatherData(locId, type)
  2274.     {
  2275.         var type = (typeof type == 'undefined') ? 0 : type; 
  2276.         var checkId = '';
  2277.         if(type == 0)
  2278.             checkId = locId +'.current';
  2279.         else
  2280.             checkId = locId +'.forcast';
  2281.             
  2282.         var status={'code':0,'time':0,'data':''};
  2283.         if(browserType == BROWSER_FF)
  2284.         {        
  2285.             var found = checkPrefPresent(checkId); 
  2286.             if(!found)
  2287.             {
  2288.                 setCharPref(checkId, ''); 
  2289.                 status.code = 1; 
  2290.             }
  2291.             else
  2292.             {
  2293.                 var data = getCharPref(checkId); 
  2294.                 var aryData = data.split('|'); 
  2295.                 if(aryData.length < 2)
  2296.                     status.code = 2;
  2297.                 else
  2298.                 {
  2299.                     status.time = aryData[0];
  2300.                     status.data = aryData[1]; 
  2301.                 }
  2302.             }
  2303.         }
  2304.         else if(browserType == BROWSER_CHROME)
  2305.         {    
  2306.             var data = localStorage.getItem(checkId); 
  2307.             if(data != null && data.length > 0)
  2308.             {
  2309.                 var aryData = data.split('|'); 
  2310.                 if(aryData.length < 2)
  2311.                     status.code = 2;
  2312.                 else
  2313.                 {
  2314.                     status.time = aryData[0];
  2315.                     status.data = aryData[1]; 
  2316.                 }
  2317.             }            
  2318.             else
  2319.                 status.code = 1; 
  2320.             updateStatus(locId+','+type+','+status.code);
  2321.         }
  2322.         
  2323.         return status; 
  2324.     }
  2325.     
  2326.     function _getWeatherDetails(force, display, event, locId)
  2327.     {
  2328.         if(queryStatus == 1)
  2329.             return; 
  2330.         
  2331.         if(event && event.button == RIGHTBUTTON)
  2332.             return; 
  2333.                     
  2334.         locId = locId ? locId : objConfigPara.locInfo[objConfigPara.defaultLocId].id;
  2335.         var now = new Date();        
  2336.         var nowms = now.getTime();
  2337.         
  2338.         var isDefault = (locId == objConfigPara.locInfo[objConfigPara.defaultLocId].id); 
  2339.         
  2340.         var forcastWeatherData = "";
  2341.         var currentWeatherData = "";
  2342.         var weatherFeedURL = '';
  2343.         
  2344.         var currentStatus = checkStoredWeatherData(locId, 0);
  2345.         var forecastStatus = checkStoredWeatherData(locId, 1);
  2346.         
  2347.         weatherUpdateMode = WEATHER_UPDATE_NONE; 
  2348.         if(forecastStatus.code != 0 || (nowms - forecastStatus.time) > forecastInterval)
  2349.         {
  2350.             //. Update all
  2351.             weatherUpdateMode = WEATHER_UPDATE_ALL; 
  2352.             weatherFeedURL = forecastWeatherFeed;
  2353.         }
  2354.         else
  2355.         {
  2356.             forcastWeatherData = forecastStatus.data; 
  2357.             if(nowms - forecastStatus.time < currentInterval)
  2358.                 currentWeatherData = forecastStatus.data;
  2359.             else if(currentStatus.code != 0 || (nowms - currentStatus.time) > currentInterval)
  2360.             {
  2361.                 //. Only update current
  2362.                 weatherUpdateMode = WEATHER_UPDATE_CURRENT; 
  2363.                 weatherFeedURL = currentWeatherFeed; 
  2364.             }
  2365.             else
  2366.                 currentWeatherData = currentStatus.data;
  2367.         }
  2368.         
  2369.         extendedWidth = objConfigPara.weatherWidth;
  2370.         displayMode = objConfigPara.displayMode;
  2371.         extendedHeight = DEFAULT_HEIGHT[displayMode]*extendedWidth/DEFAULT_WIDTH;
  2372.         fadingRatio = objConfigPara.fadingRatio;
  2373.         fadingColor = objConfigPara.fadingColor;
  2374.         noticeSpan = objConfigPara.noticeSpan;
  2375.         
  2376.         displayExtended = display; 
  2377.         
  2378.         //. loghelper('Update mode ' +weatherUpdateMode+ ' for '+ locId); 
  2379.         
  2380.         if((weatherUpdateMode & WEATHER_UPDATE_FORECAST) == 0)
  2381.         {
  2382.             parseWeatherInfo(forcastWeatherData, WEATHER_UPDATE_FORECAST, false, false); 
  2383.         }
  2384.         
  2385.         if((weatherUpdateMode & WEATHER_UPDATE_CURRENT) == 0)
  2386.         {
  2387.             parseWeatherInfo(currentWeatherData, WEATHER_UPDATE_CURRENT, false, weatherUpdateMode == WEATHER_UPDATE_NONE); 
  2388.         }
  2389.         
  2390.         if(weatherUpdateMode == WEATHER_UPDATE_NONE)
  2391.         {
  2392.             queryStatus = 2; 
  2393.  
  2394.             if(displayExtended)
  2395.             {
  2396.                 _displayExtendedWeather();
  2397.             }
  2398.             
  2399.             return; 
  2400.         }            
  2401.         
  2402.         if(weatherUpdateMode != WEATHER_UPDATE_NONE || force || event.button == LEFTBUTTON)
  2403.         {    
  2404.             queryStatus = 1; 
  2405.             xmlhttp=null;
  2406.             
  2407.             // var url = 'http://www.google.com/ig/api?weather='+objConfigPara.locationInfo.city;
  2408.             var url = weatherFeedURL.replace('[locid]', locId); 
  2409.  
  2410.             if (window.XMLHttpRequest)
  2411.             {
  2412.                 // code for all new browsers
  2413.                 xmlhttp=new XMLHttpRequest();
  2414.             }
  2415.             else if (window.ActiveXObject)
  2416.             {
  2417.                 // code for IE5 and IE6
  2418.                 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  2419.             }
  2420.             if (xmlhttp!=null)
  2421.             {
  2422.                 xmlhttp.onreadystatechange=AniWeatherInfoReady;
  2423.                 xmlhttp.open("GET",url,true);
  2424.                 xmlhttp.send(null);
  2425.             }
  2426.             else
  2427.             {
  2428.                 // alert("Error in loading the weather info.");
  2429.             }    
  2430.         }
  2431.     }
  2432.     
  2433.     function AniWeatherInfoReady()
  2434.     {            
  2435.  
  2436.         if (xmlhttp && xmlhttp.readyState==4)
  2437.         {
  2438.             // 4 = "loaded"
  2439.             if (xmlhttp.status==200)
  2440.             {
  2441.                 // 200 = OK
  2442.                 // ...our code here...
  2443.                 parseWeatherInfo(xmlhttp.responseText, weatherUpdateMode, true, true); 
  2444.             }
  2445.             else
  2446.             {
  2447.                 // Sth. wrong in getting the weather info. Try again later. 
  2448.                 queryStatus = 0; 
  2449.                 setTimeout(function(){
  2450.                             _getWeatherDetails(false, false, null); 
  2451.                     }, recheckDelay); 
  2452.             }
  2453.         }        
  2454.     }
  2455.  
  2456.     function manualParserGet(data, start, end)
  2457.     {
  2458.         var objRe = null;
  2459.         var posFrom=data.indexOf(start); 
  2460.         var posTo = data.indexOf(end); 
  2461.         if(posFrom >= 0 && posTo > 0)
  2462.         {    
  2463.             posFrom = posFrom+start.length;
  2464.             objRe = {'value':data.substr(posFrom, posTo - posFrom), 'newpos':posTo+end.length};
  2465.         }    
  2466.         return objRe; 
  2467.     }
  2468.     
  2469.     function parseWeatherInfo(data, mode, updateStorage, notify)
  2470.     {
  2471.         var updateStorage = (typeof updateStorage == "undefined") ? false : updateStorage; 
  2472.         var bProcessed = true;
  2473.         try{
  2474.             if(data.length)
  2475.             {
  2476.                 var xmlDoc = parseXML(data); 
  2477.         
  2478.                 //. Head info
  2479.                 var objElem = xmlDoc.getElementsByTagName("head")[0];
  2480.                 var aryNodes = objElem.childNodes;
  2481.                 var len = aryNodes.length; 
  2482.                 //   locale, form, ut, ud, us, up, ur
  2483.                 for(var i=0;i<len;i++)
  2484.                 {
  2485.                     var objData = aryNodes[i]; 
  2486.                     if(objData.nodeName.toLowerCase() == "locale")
  2487.                         objWeatherInfo.envInfo.locale = objData.childNodes[0].nodeValue;
  2488.                     else if(objData.nodeName.toLowerCase() == "form")
  2489.                         objWeatherInfo.envInfo.form = objData.childNodes[0].nodeValue;
  2490.                     else if(objData.nodeName.toLowerCase() == "ut")
  2491.                         objWeatherInfo.envInfo.ut = objData.childNodes[0].nodeValue;
  2492.                     else if(objData.nodeName.toLowerCase() == "ud")
  2493.                         objWeatherInfo.envInfo.ud = objData.childNodes[0].nodeValue;
  2494.                     else if(objData.nodeName.toLowerCase() == "us")
  2495.                         objWeatherInfo.envInfo.us = objData.childNodes[0].nodeValue;
  2496.                     else if(objData.nodeName.toLowerCase() == "up")
  2497.                         objWeatherInfo.envInfo.up = objData.childNodes[0].nodeValue;
  2498.                     else if(objData.nodeName.toLowerCase() == "ur")
  2499.                         objWeatherInfo.envInfo.ur = objData.childNodes[0].nodeValue;
  2500.                 }
  2501.                 //. Location info
  2502.                   objElem = xmlDoc.getElementsByTagName("loc")[0];
  2503.                 objWeatherInfo.locationInfo.localId = objElem.attributes.getNamedItem("id").value;
  2504.                 aryNodes = objElem.childNodes;
  2505.                 len = aryNodes.length; 
  2506.                 // loc, dnam, tm, lat, lon, sunr, suns, zone
  2507.                 for(var i=0;i<len;i++)
  2508.                 {
  2509.                     var objData = aryNodes[i]; 
  2510.                     if(objData.nodeName.toLowerCase() == "dnam")
  2511.                         objWeatherInfo.locationInfo.name = objData.childNodes[0].nodeValue;
  2512.                     else if(objData.nodeName.toLowerCase() == "tm")
  2513.                         objWeatherInfo.locationInfo.localtime = objData.childNodes[0].nodeValue;
  2514.                     else if(objData.nodeName.toLowerCase() == "lat")
  2515.                         objWeatherInfo.locationInfo.latitue = objData.childNodes[0].nodeValue;
  2516.                     else if(objData.nodeName.toLowerCase() == "lon")
  2517.                         objWeatherInfo.locationInfo.longitude = objData.childNodes[0].nodeValue;
  2518.                     else if(objData.nodeName.toLowerCase() == "sunr")
  2519.                         objWeatherInfo.locationInfo.sunrise = objData.childNodes[0].nodeValue;
  2520.                     else if(objData.nodeName.toLowerCase() == "suns")
  2521.                         objWeatherInfo.locationInfo.sunset = objData.childNodes[0].nodeValue;
  2522.                     else if(objData.nodeName.toLowerCase() == "zone")
  2523.                         objWeatherInfo.locationInfo.zone = objData.childNodes[0].nodeValue;
  2524.                 }
  2525.  
  2526.                 var len = objConfigPara.locInfo.length;
  2527.                 for(var i=0;i<len;i++)
  2528.                 {
  2529.                     if(objConfigPara.locInfo[i].id == objWeatherInfo.locationInfo.localId)
  2530.                         objWeatherInfo.locationInfo.name = objConfigPara.locInfo[i].name;
  2531.                 }                    
  2532.  
  2533.                 //. Links
  2534.                 objElem = xmlDoc.getElementsByTagName("lnks")[0];
  2535.                 if(objElem.attributes.getNamedItem("type").value == "prmo")
  2536.                 {
  2537.                     aryNodes = objElem.childNodes;
  2538.                     len = aryNodes.length; 
  2539.                     objWeatherInfo.links = []; 
  2540.                     for(var i=0;i<len;i++)
  2541.                     {
  2542.  
  2543.                         var objData = aryNodes[i]; 
  2544.                         if(objData.nodeName.toLowerCase() == "link")
  2545.                         {
  2546.                             var objLink = new  AniWeatherObj.Link(); 
  2547.                             var objItems = objData.childNodes;
  2548.                             var ilen = objItems.length; 
  2549.                             for(var j=0;j<ilen;j++)
  2550.                             {
  2551.                                 if(objItems[j].nodeName.toLowerCase() == "l")
  2552.                                     objLink.link = objItems[j].childNodes[0].nodeValue;
  2553.                                 else if(objItems[j].nodeName.toLowerCase() == "t")
  2554.                                     objLink.title = objItems[j].childNodes[0].nodeValue;
  2555.                             }
  2556.                             
  2557.                             objWeatherInfo.links.push(objLink); 
  2558.                         }
  2559.                     }
  2560.                 }
  2561.                 
  2562.                 if(mode & WEATHER_UPDATE_CURRENT)
  2563.                 {
  2564.                     //. current condition
  2565.                     objElem = xmlDoc.getElementsByTagName("cc")[0];
  2566.                     aryNodes = objElem.childNodes;
  2567.                     len = aryNodes.length; 
  2568.                     //   locale, form, ut, ud, us, up, ur
  2569.                     for(var i=0;i<len;i++)
  2570.                     {
  2571.                         var objData = aryNodes[i]; 
  2572.                         if(objData.nodeName.toLowerCase() == "lsup")
  2573.                             objWeatherInfo.currentInfo.time = objData.childNodes[0].nodeValue;
  2574.                         else if(objData.nodeName.toLowerCase() == "obst")
  2575.                             objWeatherInfo.currentInfo.position = objData.childNodes[0].nodeValue;
  2576.                         else if(objData.nodeName.toLowerCase() == "tmp")
  2577.                             objWeatherInfo.currentInfo.temp = objData.childNodes[0].nodeValue;
  2578.                         else if(objData.nodeName.toLowerCase() == "flik")
  2579.                             objWeatherInfo.currentInfo.feellike = objData.childNodes[0].nodeValue;
  2580.                         else if(objData.nodeName.toLowerCase() == "t")
  2581.                             objWeatherInfo.currentInfo.condition = objData.childNodes[0].nodeValue;
  2582.                         else if(objData.nodeName.toLowerCase() == "icon")
  2583.                             objWeatherInfo.currentInfo.icon = objData.childNodes[0].nodeValue;
  2584.                         else if(objData.nodeName.toLowerCase() == "hmid")
  2585.                             objWeatherInfo.currentInfo.humid = objData.childNodes[0].nodeValue;
  2586.                         else if(objData.nodeName.toLowerCase() == "vis")
  2587.                             objWeatherInfo.currentInfo.visible = objData.childNodes[0].nodeValue;
  2588.                         else if(objData.nodeName.toLowerCase() == "uv")
  2589.                         {
  2590.                             var objItems = objData.childNodes;
  2591.                             var ilen = objItems.length; 
  2592.                             for(var j=0;j<ilen;j++)
  2593.                             {
  2594.                                 if(objItems[j].nodeName.toLowerCase() == "i")
  2595.                                     objWeatherInfo.currentInfo.uvvalue = objItems[j].childNodes[0].nodeValue;
  2596.                                 else if(objItems[j].nodeName.toLowerCase() == "t")
  2597.                                     objWeatherInfo.currentInfo.uvlevel = objItems[j].childNodes[0].nodeValue;
  2598.                             }                    
  2599.                         }
  2600.                         else if(objData.nodeName.toLowerCase() == "moon")
  2601.                         {
  2602.                             var objItems = objData.childNodes;
  2603.                             var ilen = objItems.length; 
  2604.                             for(var j=0;j<ilen;j++)
  2605.                             {
  2606.                                 if(objItems[j].nodeName.toLowerCase() == "icon")
  2607.                                     objWeatherInfo.currentInfo.moonicon = objItems[j].childNodes[0].nodeValue;
  2608.                                 else if(objItems[j].nodeName.toLowerCase() == "t")
  2609.                                     objWeatherInfo.currentInfo.moondesc = objItems[j].childNodes[0].nodeValue;
  2610.                             }                    
  2611.                         }    
  2612.                         else if(objData.nodeName.toLowerCase() == "wind")
  2613.                         {
  2614.                             var objItems = objData.childNodes;
  2615.                             var ilen = objItems.length; 
  2616.                             for(var j=0;j<ilen;j++)
  2617.                             {
  2618.                     
  2619.                                 if(objItems[j].nodeName.toLowerCase() == "s")
  2620.                                 {
  2621.                                     objWeatherInfo.currentInfo.windspeed = objItems[j].childNodes[0].nodeValue;
  2622.                                 }
  2623.                                 if(objItems[j].nodeName.toLowerCase() == "t")
  2624.                                     objWeatherInfo.currentInfo.winddir = objItems[j].childNodes[0].nodeValue;
  2625.                             }                    
  2626.                         }                        
  2627.                     }                
  2628.                 }
  2629.                 
  2630.                 if(mode & WEATHER_UPDATE_FORECAST)
  2631.                 {
  2632.                     //. forcast
  2633.                     objElem = xmlDoc.getElementsByTagName("dayf")[0];
  2634.                     aryNodes = objElem.childNodes;
  2635.                     len = aryNodes.length; 
  2636.                     objWeatherInfo.dailyInfo = [];
  2637.                     for(var i=0;i<len;i++)
  2638.                     {
  2639.                         var objData = aryNodes[i]; 
  2640.                         if(objData.nodeName.toLowerCase() == "lsup" && objWeatherInfo.currentInfo.time.length == 0)
  2641.                             objWeatherInfo.currentInfo.time = objData.childNodes[0].nodeValue;
  2642.                         else if(objData.nodeName.toLowerCase() == "day")
  2643.                         {
  2644.                             var dayIdx = parseInt(objData.attributes.getNamedItem("d").value);
  2645.                             objWeatherInfo.dailyInfo[dayIdx] = getDayInfo(objData); 
  2646.                         }
  2647.                     }
  2648.                 }
  2649.             }
  2650.             
  2651.         }catch(e){
  2652.             // alert(e.toString()); 
  2653.             try{
  2654.         
  2655.                 //. Manual parsing due to Chrome's bug in XMLParser
  2656.                 //. Head info                
  2657.                 objWeatherInfo.locationInfo.name = "UNAVAILABLE";
  2658.                 
  2659.                 //. Location info
  2660.                 
  2661.                 var objVal = manualParserGet(data, '<loc ', '<dnam>').value;
  2662.                 objWeatherInfo.locationInfo.localId = manualParserGet(objVal, 'id="', '">').value;
  2663.                 objWeatherInfo.locationInfo.name = manualParserGet(data, '<dnam>', '</dnam>').value;
  2664.  
  2665.                 
  2666.                 //. Links
  2667.                 objVal = manualParserGet(data, '<lnks', '</lnks>').value; 
  2668.                 
  2669.                 while(true)
  2670.                 {
  2671.                     var objLink = manualParserGet(objVal, '<link', '</link>'); 
  2672.                     if(objLink)
  2673.                     {
  2674.                         var linkVal = objLink.value;
  2675.                         var link = manualParserGet(linkVal, '<l>', '</l>').value; 
  2676.                         var title = manualParserGet(linkVal, '<t>', '</t>').value; 
  2677.                         objWeatherInfo.links.push({'title':title, 'link':link}); 
  2678.                         
  2679.                         objVal = objVal.substr(objLink.newpos);                     
  2680.                     }
  2681.                     else
  2682.                         break;
  2683.                 }
  2684.                 
  2685.                 //. current condition
  2686.                 objVal = manualParserGet(data, '<cc>', '</cc>').value; 
  2687.                 objWeatherInfo.currentInfo.time = manualParserGet(objVal, '<lsup>', '</lsup>').value;
  2688.                 objWeatherInfo.currentInfo.temp = manualParserGet(objVal, '<tmp>', '</tmp>').value;
  2689.                 objWeatherInfo.currentInfo.condition = manualParserGet(objVal, '<t>', '</t>').value;
  2690.                 objWeatherInfo.currentInfo.icon = manualParserGet(objVal, '<icon>', '</icon>').value;
  2691.                 
  2692.                 objVal = manualParserGet(objVal, '<wind>', '</wind>').value; 
  2693.                 objWeatherInfo.currentInfo.windspeed = manualParserGet(objVal, '<s>', '</s>').value;
  2694.                 objWeatherInfo.currentInfo.winddir = manualParserGet(objVal, '<t>', '</t>').value;            
  2695.                 
  2696.                 //. forcast
  2697.                 objWeatherInfo.dailyInfo = [];
  2698.                 objVal = manualParserGet(data, '<dayf', '</dayf>').value; 
  2699.                 if(objVal)
  2700.                 {
  2701.                     if(objWeatherInfo.currentInfo.time.length == 0)
  2702.                         objWeatherInfo.currentInfo.time = manualParserGet(objVal, '<lsup>', '</lsup>').value;
  2703.                     while(true)
  2704.                     {
  2705.                         var objDay = manualParserGet(objVal, '<day', '</day>');
  2706.                         if(objDay)
  2707.                         {
  2708.                             var dayVal = objDay.value; 
  2709.                             var objDaily = new  AniWeatherObj.DailyWeatherInfo(); 
  2710.                             
  2711.                             objDaily.highTemp = manualParserGet(dayVal, '<hi>', '</hi>').value;
  2712.                             objDaily.lowTemp = manualParserGet(dayVal, '<low>', '</low>').value;
  2713.  
  2714.                             var partVal = manualParserGet(objVal, 'p="d"', '</part>').value;
  2715.                             objDaily.dayicon = manualParserGet(partVal, '<icon>', '</icon>').value;
  2716.                             objDaily.daycond = manualParserGet(partVal, '<t>', '</t>').value;
  2717.                             objWeatherInfo.dailyInfo.push(objDaily); 
  2718.                             
  2719.                             objVal = objVal.substr(objDay.newpos);                     
  2720.  
  2721.                         }    
  2722.                         else
  2723.                             break;
  2724.                     }
  2725.                 }
  2726.             }catch(e){
  2727.                 bProcessed = false; 
  2728.             }
  2729.         }
  2730.         
  2731.         try{
  2732.             if(!bProcessed)
  2733.             {
  2734.                 queryStatus = 0; 
  2735.                 setTimeout(function(){
  2736.                             _getWeatherDetails(false, false, null); 
  2737.                 }, recheckDelay); 
  2738.                 return; 
  2739.             }
  2740.             
  2741.             if((mode & WEATHER_UPDATE_CURRENT) && objWeatherInfo.currentInfo.time.length > 0)
  2742.             {
  2743.                 getDateInfo(objWeatherInfo.currentInfo.time);
  2744.                 updateTodayCondition(); 
  2745.             }
  2746.             
  2747.             weatherHelperString = getWeatherHelperString();
  2748.  
  2749.             if(displayExtended)
  2750.                 _displayExtendedWeather(); 
  2751.             
  2752.             var now = new Date();
  2753.             timeLastCheck = now.getTime(); 
  2754.             queryStatus = 2; 
  2755.             
  2756.             if(updateStorage)
  2757.             {
  2758.                 var name='';
  2759.                 if(mode & WEATHER_UPDATE_FORECAST)
  2760.                     name = objWeatherInfo.locationInfo.localId+'.forcast';
  2761.                 else if(mode & WEATHER_UPDATE_CURRENT)
  2762.                     name = objWeatherInfo.locationInfo.localId+'.current';
  2763.                 
  2764.                 var val = timeLastCheck+'|'+data; 
  2765.                 if(browserType == BROWSER_FF)
  2766.                     setCharPref(name,  val); 
  2767.                 else if(browserType == BROWSER_CHROME)
  2768.                     localStorage.setItem(name,  val);                
  2769.             }
  2770.             
  2771.             updateWeatherInfo(objWeatherInfo.locationInfo.localId == objConfigPara.locInfo[objConfigPara.defaultLocId].id, notify); 
  2772.         }catch(e){alert(e.toString());}
  2773.     }    
  2774.  
  2775.     function updateWeatherInfo(isDefault, notify)
  2776.     {
  2777.         if(isDefault)
  2778.         {
  2779.             updatePanelIcon(); 
  2780.             weatherDefaultString = weatherHelperString;
  2781.             objDefaultWeatherInfo.copyWeatherInfo(objWeatherInfo); 
  2782.         }
  2783.             
  2784.         if(browserType == BROWSER_FF)
  2785.         {
  2786.             // setIntPref('locChanged', 0)    
  2787.             
  2788.             if(objConfigPara.noticeSpan > 0 && checkIndex == objConfigPara.noticeSpan)
  2789.             {
  2790.                 checkIndex = 0; 
  2791.                 setTimeout(onAutoWeatherNotice, autoNoticeDelay);     
  2792.             }    
  2793.         }
  2794.         else if(browserType == BROWSER_CHROME)
  2795.         {
  2796.             var idWeatherString;
  2797.             var idChkWeather;
  2798.             if(isDefault)
  2799.             {
  2800.                 idWeatherString = 'hiddenWeatherString';
  2801.                 idChkWeather = 'chkWeatherReady';
  2802.             }        
  2803.             else
  2804.             {
  2805.                 idWeatherString = 'hiddenOtherWeatherString';
  2806.                 idChkWeather = 'chkOtherWeatherReady';
  2807.             }    
  2808.         
  2809.  
  2810.             var objString = document.getElementById(idWeatherString);
  2811.             objString.setAttribute("value", weatherHelperString);
  2812.  
  2813.             var chkWeather = document.getElementById(idChkWeather);
  2814.             chkWeather.checked = true; 
  2815.             
  2816.             if(notify)
  2817.                 chkWeather.onclick(); 
  2818.  
  2819.             //. TODO: update weather icon. 
  2820.         }
  2821.     }
  2822.     
  2823.     function onAutoWeatherNotice()
  2824.     {
  2825.         displayLauncher(getCurDocument(), weatherHelperString, null, true); 
  2826.     }
  2827.     
  2828.     function onUpdatePanelIcon(event)
  2829.     {
  2830.         var objPanel = document.getElementById('aniweatherstatus_current'); 
  2831.         if(objPanel)
  2832.         {
  2833.             clearInterval(tmSetPanelIcon); 
  2834.             tmSetPanelIcon = null;             
  2835.  
  2836.             updatePanelIcon(); 
  2837.         }
  2838.     }
  2839.     
  2840.     function getTempValue(temp, unit)
  2841.     {
  2842.         var tempUnit = (typeof unit == "undefined") ? objConfigPara.tempUnit : unit;
  2843.  
  2844.         var tempVal = parseInt(temp);
  2845.         if(temp == "N/A")
  2846.             tempVal = "";
  2847.         else if(tempUnit == 1)
  2848.             tempVal = Math.round(5*(tempVal-32)/9)+' \u00b0C';
  2849.         else
  2850.             tempVal = tempVal+' \u00b0F';    
  2851.         
  2852.         return tempVal; 
  2853.     }
  2854.     
  2855.     function getWindValue(wind)
  2856.     {
  2857.         var windSpeed = "";
  2858.         var speed = parseInt(wind);
  2859.         if(speed > 0)
  2860.         {
  2861.             if(objConfigPara.windUnit == 1)
  2862.                 windSpeed = ", " + Math.round(mph2kmh * speed) + " " + getLocaleString('display.kmh');
  2863.             else
  2864.                 windSpeed = ", "+ speed + " " + getLocaleString('display.mph');
  2865.         }
  2866.         
  2867.         return windSpeed;
  2868.  
  2869.     }    
  2870.     
  2871.     function getElemHelper(id)
  2872.     {
  2873.         return document.getElementById(id); 
  2874.     }
  2875.     
  2876.     function updateGraphIcons()
  2877.     {
  2878.         getElemHelper('aniweatherpanel_national').style.display = (objConfigPara.graphLevel['national'].show == 1) ? "block" : "none";
  2879.         getElemHelper('aniweatherpanel_vapor').style.display = (objConfigPara.graphLevel['vapor'].show == 1) ? "block" : "none";
  2880.         getElemHelper('aniweatherpanel_radar').style.display = (objConfigPara.graphLevel['radar'].show == 1) ? "block" : "none";
  2881.         getElemHelper('aniweatherpanel_uv').style.display = (objConfigPara.graphLevel['uv'].show  == 1)? "block" : "none";
  2882.         getElemHelper('aniweatherpanel_pop').style.display = (objConfigPara.graphLevel['pop'].show == 1) ? "block" : "none";
  2883.         getElemHelper('aniweatherpanel_high').style.display = (objConfigPara.graphLevel['high'].show == 1) ? "block" : "none";
  2884.         getElemHelper('aniweatherpanel_air').style.display = (objConfigPara.graphLevel['air'].show == 1) ? "block" : "none";
  2885.         getElemHelper('aniweatherpanel_alert').style.display = (objConfigPara.graphLevel['alert'].show == 1) ? "block" : "none";
  2886.     }    
  2887.     
  2888.     function updatePanelDay(day, dayname, level, icon, desc, temp)
  2889.     {
  2890.         var disp = "";
  2891.         var baseURL;
  2892.         if(browserType == BROWSER_FF)
  2893.         {
  2894.             baseURL = "chrome://aniweather/skin/conditions/";
  2895.             disp = "block"; 
  2896.         }
  2897.         else if(browserType == BROWSER_CHROME)
  2898.         {
  2899.             baseURL = "chrome-extension://kjehacgbekgldmillhggcabflamgkapc/res/conditions/";
  2900.             disp = "inline"; 
  2901.         }
  2902.         
  2903.         var obj = getElemHelper('aniweatherstatus_'+day);
  2904.         obj.src = baseURL+""+icon+".png";     
  2905.         if(level.showicon == 1)
  2906.             obj.style.display = disp;
  2907.         else
  2908.             obj.style.display = "none";            
  2909.         
  2910.         var strLabel = dayname+": ";
  2911.         if(level.showdesc == 1)    
  2912.         {
  2913.             strLabel = strLabel + desc;
  2914.             if(level.showtemp == 1)
  2915.                 strLabel = strLabel + ',';
  2916.         }    
  2917.         
  2918.         if(level.showtemp == 1)
  2919.             strLabel = strLabel + getTempValue(temp, objConfigPara.tempUnit);  
  2920.         
  2921.         getElemHelper('aniweatherpanel_'+day).style.display = (level.show == 1) ? disp : "none";
  2922.         var obj = getElemHelper('aniweatherlabel_'+day);
  2923.         
  2924.         if(browserType == BROWSER_FF)
  2925.             obj.value = strLabel;
  2926.         else if(browserType == BROWSER_CHROME)
  2927.             obj.innerHTML = strLabel;
  2928.         // obj.style.display = disp;     
  2929.     }
  2930.     
  2931.     function updatePanelIcon()
  2932.     {
  2933.         if(browserType == BROWSER_FF)
  2934.         {
  2935.             var objPanel = getElemHelper('aniweatherstatus_current'); 
  2936.             
  2937.             if(!objPanel)
  2938.             {
  2939.                 if(tmSetPanelIcon)
  2940.                     clearInterval(tmSetPanelIcon); 
  2941.                     
  2942.                 tmSetPanelIcon = setInterval(onUpdatePanelIcon, 500); 
  2943.                 return; 
  2944.             }            
  2945.         }
  2946.  
  2947.         try{
  2948.         updatePanelDay("current", getLocaleString('fullweekday.now'), objConfigPara.displayLevel['current'], 
  2949.             objWeatherInfo.currentInfo.icon, objWeatherInfo.currentInfo.condition, objWeatherInfo.currentInfo.temp)            
  2950.         
  2951.         var temp = objWeatherInfo.dailyInfo[0].highTemp;
  2952.         if(temp == "N/A") temp = objWeatherInfo.currentInfo.temp;
  2953.         updatePanelDay("today", getLocaleString('fullweekday.today'), objConfigPara.displayLevel['today'], 
  2954.             objWeatherInfo.dailyInfo[0].dayicon, objWeatherInfo.dailyInfo[0].daycond, temp)            
  2955.         
  2956.         updatePanelDay("2nd", getLocaleString('weekdays.' + objWeatherInfo.dailyInfo[1].weekday.toLowerCase()), objConfigPara.displayLevel['2nd'], 
  2957.             objWeatherInfo.dailyInfo[1].dayicon, objWeatherInfo.dailyInfo[1].daycond, objWeatherInfo.dailyInfo[1].highTemp)            
  2958.     
  2959.         updatePanelDay("3rd", getLocaleString('weekdays.' + objWeatherInfo.dailyInfo[2].weekday.toLowerCase()), objConfigPara.displayLevel['3rd'], 
  2960.             objWeatherInfo.dailyInfo[2].dayicon, objWeatherInfo.dailyInfo[2].daycond, objWeatherInfo.dailyInfo[2].highTemp)            
  2961.         
  2962.         updatePanelDay("4th", getLocaleString('weekdays.' + objWeatherInfo.dailyInfo[3].weekday.toLowerCase()), objConfigPara.displayLevel['4th'], 
  2963.             objWeatherInfo.dailyInfo[3].dayicon, objWeatherInfo.dailyInfo[3].daycond, objWeatherInfo.dailyInfo[3].highTemp)            
  2964.         
  2965.         updatePanelDay("5th", getLocaleString('weekdays.' + objWeatherInfo.dailyInfo[4].weekday.toLowerCase()), objConfigPara.displayLevel['5th'], 
  2966.             objWeatherInfo.dailyInfo[4].dayicon, objWeatherInfo.dailyInfo[4].daycond, objWeatherInfo.dailyInfo[4].highTemp)            
  2967.         }catch(e){}
  2968.         
  2969.         updateGraphIcons();
  2970.         
  2971.         if(browserType == BROWSER_FF)
  2972.         {
  2973.             //remove old first-last attribute
  2974.             var objHolder = document.getElementById("aniweather_box");
  2975.             var aryCanvas = objHolder.getElementsByTagName("awcanvas");
  2976.             var len = aryCanvas.length; 
  2977.             var objFirstVisible = null;
  2978.             var objLastVisible = null; 
  2979.             var leftmost = 999999; // Large enough
  2980.             var rightmost = -1;     // Small enough
  2981.             for (var i=0; i<len; i++) 
  2982.             {
  2983.                 var objElem = aryCanvas[i];
  2984.                 if(objElem && objElem.getBoundingClientRect)
  2985.                 {
  2986.                     var rect = objElem.getBoundingClientRect(); 
  2987.                     if(objElem.style.display != 'none' && rect.left < leftmost)
  2988.                     {
  2989.                         leftmost = rect.left;
  2990.                         objFirstVisible = objElem; 
  2991.                     }
  2992.                     
  2993.                     if(objElem.style.display != 'none' && rect.left > rightmost)
  2994.                     {
  2995.                         rightmost = rect.left;
  2996.                         objLastVisible = objElem; 
  2997.                     }
  2998.                   
  2999.                     objElem.removeAttribute("aw-first");
  3000.                     objElem.removeAttribute("aw-last");
  3001.                 }
  3002.                 else
  3003.                     break;
  3004.             }
  3005.             
  3006.             if(objFirstVisible)
  3007.                 objFirstVisible.setAttribute("aw-first", "true");  
  3008.             if(objLastVisible)
  3009.                 objLastVisible.setAttribute("aw-last", "true");          
  3010.         }
  3011.     }
  3012.  
  3013.     
  3014.     function getDayInfo(objDay)
  3015.     {
  3016.         var objDaily = new  AniWeatherObj.DailyWeatherInfo(); 
  3017.         var objItems = objDay.childNodes;
  3018.         var ilen = objItems.length; 
  3019.         for(var i=0;i<ilen;i++)
  3020.         {
  3021.             var objItem = objItems[i];
  3022.             if(objItem.nodeName.toLowerCase() == "hi")
  3023.                 objDaily.highTemp = objItem.childNodes[0].nodeValue;
  3024.             else if(objItem.nodeName.toLowerCase() == "low")
  3025.                 objDaily.lowTemp = objItem.childNodes[0].nodeValue;
  3026.             else if(objItem.nodeName.toLowerCase() == "sunr")
  3027.                 objDaily.sunrise = objItem.childNodes[0].nodeValue;
  3028.             else if(objItem.nodeName.toLowerCase() == "suns")
  3029.                 objDaily.sunset = objItem.childNodes[0].nodeValue;
  3030.             else if(objItem.nodeName.toLowerCase() == "part")
  3031.             {
  3032.                 if(objItem.attributes.getNamedItem("p").value == "d")
  3033.                 {
  3034.                     var objParts = objItem.childNodes;
  3035.                     var plen = objParts.length; 
  3036.                     for(var j=0;j<plen;j++)
  3037.                     {
  3038.                         var objPart = objParts[j]; 
  3039.                         if(objPart.nodeName.toLowerCase() == "icon")
  3040.                             objDaily.dayicon = objPart.childNodes[0].nodeValue;
  3041.                         else if(objPart.nodeName.toLowerCase() == "t")
  3042.                             objDaily.daycond = objPart.childNodes[0].nodeValue;
  3043.                         else if(objPart.nodeName.toLowerCase() == "ppcp")
  3044.                             objDaily.dayppcp = objPart.childNodes[0].nodeValue;
  3045.                         else if(objPart.nodeName.toLowerCase() == "hmid")
  3046.                             objDaily.dayhumid = objPart.childNodes[0].nodeValue;
  3047.                         else if(objPart.nodeName.toLowerCase() == "wind")
  3048.                         {
  3049.                             var objElems = objPart.childNodes;
  3050.                             var wlen = objElems.length; 
  3051.                             for(var k=0;k<wlen;k++)
  3052.                             {
  3053.                                 if(objElems[k].nodeName.toLowerCase() == "s")
  3054.                                     objDaily.daywindspeed = objElems[k].childNodes[0].nodeValue;
  3055.                                 else if(objElems[k].nodeName.toLowerCase() == "t")
  3056.                                     objDaily.daywinddir = objElems[k].childNodes[0].nodeValue;
  3057.                             }                            
  3058.                         }
  3059.                     }
  3060.                 }    
  3061.                 else if(objItem.attributes.getNamedItem("p").value == "n")
  3062.                 {
  3063.                     var objParts = objItem.childNodes;
  3064.                     var plen = objParts.length; 
  3065.                     for(var j=0;j<plen;j++)
  3066.                     {
  3067.                         var objPart = objParts[j]; 
  3068.                     
  3069.                         if(objPart.nodeName.toLowerCase() == "icon")
  3070.                             objDaily.nighticon = objPart.childNodes[0].nodeValue;
  3071.                         else if(objPart.nodeName.toLowerCase() == "t")
  3072.                             objDaily.nightcond = objPart.childNodes[0].nodeValue;
  3073.                         else if(objPart.nodeName.toLowerCase() == "ppcp")
  3074.                             objDaily.nightppcp = objPart.childNodes[0].nodeValue;
  3075.                         else if(objPart.nodeName.toLowerCase() == "hmid")
  3076.                             objDaily.nighthumid = objPart.childNodes[0].nodeValue;
  3077.                         else if(objPart.nodeName.toLowerCase() == "wind")
  3078.                         {
  3079.                             var objElems = objPart.childNodes;
  3080.                             var wlen = objElems.length; 
  3081.                             for(var k=0;k<wlen;k++)
  3082.                             {
  3083.                                 if(objElems[k].nodeName.toLowerCase() == "s")
  3084.                                     objDaily.nightwindspeed = objElems[k].childNodes[0].nodeValue;
  3085.                                 else if(objElems[k].nodeName.toLowerCase() == "t")
  3086.                                     objDaily.nightwinddir = objElems[k].childNodes[0].nodeValue;
  3087.                             }                            
  3088.                         }
  3089.                     }
  3090.  
  3091.                 }                    
  3092.             }                                    
  3093.         }    
  3094.  
  3095.         return objDaily; 
  3096.     }
  3097.     
  3098.     function updateTodayCondition()
  3099.     {
  3100.         // if(objWeatherInfo.dailyInfo[0].highTemp == "N/A")
  3101.         //     objWeatherInfo.dailyInfo[0].highTemp = objWeatherInfo.dailyInfo[0].lowTemp; 
  3102.  
  3103.         if(objWeatherInfo.dailyInfo[0].daycond == "N/A")
  3104.         {
  3105.             objWeatherInfo.passToday = true;
  3106.             objWeatherInfo.dailyInfo[0].daycond = objWeatherInfo.currentInfo.condition; 
  3107.         }
  3108.         else
  3109.             objWeatherInfo.passToday = false;
  3110.             
  3111.         if(objWeatherInfo.dailyInfo[0].dayicon == "25" || objWeatherInfo.dailyInfo[0].dayicon == "44") // N/A
  3112.             objWeatherInfo.dailyInfo[0].dayicon = objWeatherInfo.currentInfo.icon; 
  3113.             
  3114.         if(objWeatherInfo.dailyInfo[0].daywindspeed == "N/A")
  3115.             objWeatherInfo.dailyInfo[0].daywindspeed = objWeatherInfo.currentInfo.windspeed; 
  3116.  
  3117.         if(objWeatherInfo.dailyInfo[0].daywinddir == "N/A")
  3118.             objWeatherInfo.dailyInfo[0].daywinddir = objWeatherInfo.currentInfo.winddir; 
  3119.             
  3120.         if(objWeatherInfo.dailyInfo[0].dayhumid == "N/A")
  3121.             objWeatherInfo.dailyInfo[0].dayhumid = objWeatherInfo.currentInfo.humid; 
  3122.     }
  3123.     
  3124.     function getCurDocument()
  3125.     {
  3126.         var doc = null; 
  3127.         if(browserType == BROWSER_FF)
  3128.         {
  3129.             doc = gBrowser.selectedBrowser.contentDocument;
  3130.         }
  3131.         else if(browserType == BROWSER_CHROME)
  3132.         {
  3133.             doc = document; 
  3134.         }
  3135.             
  3136.         var aryFrames = doc.getElementsByTagName('frame'); 
  3137.         var len = aryFrames.length;
  3138.         
  3139.         var maxArea = 0; 
  3140.         var maxId = -1;
  3141.         for(var i=0;i<len;i++)
  3142.         {
  3143.             var docFrame = aryFrames[i].contentWindow.document; 
  3144.             var wndFrame = GetClientWindow(docFrame); 
  3145.             var width = docFrame.documentElement.clientWidth;
  3146.             var height = docFrame.documentElement.clientHeight;
  3147.             var left = aryFrames[i].offsetLeft;
  3148.             var top = aryFrames[i].offsetTop;
  3149.             
  3150.             if(maxArea < width*height)
  3151.             {
  3152.                 maxArea = width*height;
  3153.                 maxId = i;
  3154.             }
  3155.         }
  3156.  
  3157.         if(maxId != -1)
  3158.         {
  3159.             doc = aryFrames[maxId].contentWindow.document; 
  3160.         }
  3161.             
  3162.         return doc; 
  3163.     }
  3164.     
  3165.     function GetClientWindow(doc)
  3166.     {
  3167.         if(browserType == BROWSER_FF)
  3168.         {
  3169.  
  3170.             var wndClient = null;     
  3171.             
  3172.             if( document && document.commandDispatcher && document.commandDispatcher.focusedWindow && 
  3173.                 document.commandDispatcher.focusedWindow.toString() != "[object ChromeWindow]")
  3174.  
  3175.                 wndClient = document.commandDispatcher.focusedWindow; 
  3176.  
  3177.             else if(doc && doc.defaultView)
  3178.                 wndClient = doc.defaultView;             
  3179.             
  3180.             return wndClient;
  3181.  
  3182.         }
  3183.         else
  3184.         {
  3185.             if(doc && typeof doc.defaultView != "undefined")
  3186.                 return  doc.defaultView;
  3187.                 
  3188.             return window; 
  3189.         }
  3190.     }
  3191.     
  3192.     function getPixel(pxl)
  3193.     {
  3194.         return pxl + ((browserType == BROWSER_IE) ? "" : "px"); 
  3195.     }
  3196.     
  3197.     function getClientRect(doc, win) 
  3198.     {
  3199.         var width = 0;
  3200.         var height = 0;
  3201.         var left = 0; 
  3202.         var top = 0; 
  3203.  
  3204.         if(win && win.innerWidth) 
  3205.         {
  3206.             width = win.innerWidth;
  3207.             height = win.innerHeight;
  3208.         }        
  3209.         else if( doc.body && ( doc.body.clientWidth || doc.body.clientHeight ) ) 
  3210.         {
  3211.             width = doc.body.clientWidth;
  3212.             height = doc.body.clientHeight;
  3213.         }            
  3214.         else if(doc &&  doc.documentElement && doc.documentElement.clientWidth && documentdoc.clientHeight) 
  3215.         {
  3216.             width = doc.documentElement.clientWidth;
  3217.             height = doc.documentElement.clientHeight;
  3218.         }    
  3219.         
  3220.         left = win.pageXOffset ? win.pageXOffset : 
  3221.                 doc.documentElement ? doc.documentElement.scrollLeft : 
  3222.                     doc.body ? doc.body.scrollLeft : 0;
  3223.         
  3224.         top = win.pageYOffset ? win.pageYOffset : 
  3225.                 doc.documentElement ? doc.documentElement.scrollTop : 
  3226.                     doc.body ? doc.body.scrollTop : 0;
  3227.         
  3228.         return {'left': left, 'top':top, 'width':width, 'height':height};
  3229.     }    
  3230.     
  3231.     function setOpacity(style, value)
  3232.     {
  3233.         if(browserType == BROWSER_IE)
  3234.             style.filter = "alpha(opacity = "+value+");";
  3235.         else
  3236.             style.opacity = value*0.01;
  3237.     }
  3238.     
  3239.     function removeWeather(removeMini, removeExtended)
  3240.     {        
  3241.         var doc = getCurDocument(); 
  3242.         var status = -1; 
  3243.         var objLauncher = doc.getElementById(weatherLauncherId); 
  3244.         if(objLauncher)
  3245.             doc.body.removeChild(objLauncher); 
  3246.         
  3247.         if(removeExtended)
  3248.         {
  3249.             var divExtendedHolder = doc.getElementById(extendedHolderId); 
  3250.  
  3251.             if(divExtendedHolder)
  3252.             {
  3253.                 doc.body.removeChild(divExtendedHolder); 
  3254.                 status = 0; 
  3255.             }
  3256.         }
  3257.  
  3258.         if(removeMini)
  3259.         {
  3260.             var divMiniHolder = doc.getElementById(miniHolderId); 
  3261.             if(divMiniHolder)
  3262.                 doc.body.removeChild(divMiniHolder);
  3263.         }    
  3264.         
  3265.         return status; 
  3266.     }
  3267.     
  3268.     function getWeatherHelperString()
  3269.     {
  3270.         var strParas = ''; 
  3271.         var windspeed = getWindValue(objWeatherInfo.currentInfo.windspeed);
  3272.         
  3273.         /*
  3274.         strParas = 'city='+objWeatherInfo.locationInfo.name+'&iconbase='+iconBaseUrl+'&locid='+objWeatherInfo.locationInfo.localId+'&nowtemp='+objWeatherInfo.currentInfo.temp+'&nowcond='+objWeatherInfo.currentInfo.condition+'&wind=Wind '+objWeatherInfo.currentInfo.winddir+windspeed+'&nowicon='+objWeatherInfo.currentInfo.icon+'&unit='+objConfigPara.tempUnit+','+objConfigPara.windUnit+'&vis='+objWeatherInfo.currentInfo.visible+'&hum='+objWeatherInfo.currentInfo.humid+'&uv='+objWeatherInfo.currentInfo.uvvalue+' ('+objWeatherInfo.currentInfo.uvlevel+')'+'&dates='+objWeatherInfo.dates+","+'&weekdays='+objWeatherInfo.days+'&winds='+objWeatherInfo.dailyInfo[0].daywindspeed+','+objWeatherInfo.dailyInfo[1].daywindspeed+','+objWeatherInfo.dailyInfo[2].daywindspeed+','+objWeatherInfo.dailyInfo[3].daywindspeed+','+objWeatherInfo.dailyInfo[4].daywindspeed+'&humids='+objWeatherInfo.dailyInfo[0].dayhumid+','+objWeatherInfo.dailyInfo[1].dayhumid+','+objWeatherInfo.dailyInfo[2].dayhumid+','+objWeatherInfo.dailyInfo[3].dayhumid+','+objWeatherInfo.dailyInfo[4].dayhumid+'&ppcps='+objWeatherInfo.dailyInfo[0].dayppcp+','+objWeatherInfo.dailyInfo[1].dayppcp+','+objWeatherInfo.dailyInfo[2].dayppcp+','+objWeatherInfo.dailyInfo[3].dayppcp+','+objWeatherInfo.dailyInfo[4].dayppcp+'&lows='+objWeatherInfo.dailyInfo[0].lowTemp+','+objWeatherInfo.dailyInfo[1].lowTemp+','+objWeatherInfo.dailyInfo[2].lowTemp+','+objWeatherInfo.dailyInfo[3].lowTemp+','+objWeatherInfo.dailyInfo[4].lowTemp+'&highs='+objWeatherInfo.dailyInfo[0].highTemp+','+objWeatherInfo.dailyInfo[1].highTemp+','+objWeatherInfo.dailyInfo[2].highTemp+','+objWeatherInfo.dailyInfo[3].highTemp+','+objWeatherInfo.dailyInfo[4].highTemp+'&conditions='+objWeatherInfo.dailyInfo[0].daycond+','+objWeatherInfo.dailyInfo[1].daycond+','+objWeatherInfo.dailyInfo[2].daycond+','+objWeatherInfo.dailyInfo[3].daycond+','+objWeatherInfo.dailyInfo[4].daycond+'&codes='+objWeatherInfo.dailyInfo[0].dayicon+','+objWeatherInfo.dailyInfo[1].dayicon+','+objWeatherInfo.dailyInfo[2].dayicon+','+objWeatherInfo.dailyInfo[3].dayicon+','+objWeatherInfo.dailyInfo[4].dayicon+'&linktitles='+objWeatherInfo.links[0].title+','+objWeatherInfo.links[1].title+','+objWeatherInfo.links[2].title+','+objWeatherInfo.links[3].title+'&linkurls='+escape(objWeatherInfo.links[0].link)+','+escape(objWeatherInfo.links[1].link)+','+escape(objWeatherInfo.links[2].link)+','+escape(objWeatherInfo.links[3].link);
  3275.         */        
  3276.         
  3277.         var mp = objWeatherInfo.currentInfo.moonicon;
  3278.         var strPhases = mp;
  3279.         for(var i=0;i<4;i++)
  3280.         {
  3281.             mp++;
  3282.             if(mp >= 30)
  3283.                 mp -= 30;
  3284.             strPhases = strPhases +','+ mp;
  3285.         }
  3286.         
  3287.         
  3288.         strParas = 'city='+objWeatherInfo.locationInfo.name+'&iconbase='+iconBaseUrl+'&locid='+objWeatherInfo.locationInfo.localId+'&nowtemp='+objWeatherInfo.currentInfo.temp+'&nowcond='+objWeatherInfo.currentInfo.condition+'&wind=Wind '+objWeatherInfo.currentInfo.winddir+windspeed+'&nowicon='+objWeatherInfo.currentInfo.icon+'&unit='+objConfigPara.tempUnit+','+objConfigPara.windUnit+'&vis='+objWeatherInfo.currentInfo.visible+'&hum='+objWeatherInfo.currentInfo.humid+'&uv='+objWeatherInfo.currentInfo.uvvalue+' ('+objWeatherInfo.currentInfo.uvlevel+')'+'&dates='+objWeatherInfo.dates+","+'&weekdays='+objWeatherInfo.days+'&winds='+objWeatherInfo.dailyInfo[0].daywindspeed+','+objWeatherInfo.dailyInfo[1].daywindspeed+','+objWeatherInfo.dailyInfo[2].daywindspeed+','+objWeatherInfo.dailyInfo[3].daywindspeed+','+objWeatherInfo.dailyInfo[4].daywindspeed+'&humids='+objWeatherInfo.dailyInfo[0].dayhumid+','+objWeatherInfo.dailyInfo[1].dayhumid+','+objWeatherInfo.dailyInfo[2].dayhumid+','+objWeatherInfo.dailyInfo[3].dayhumid+','+objWeatherInfo.dailyInfo[4].dayhumid+'&ppcps='+objWeatherInfo.dailyInfo[0].dayppcp+','+objWeatherInfo.dailyInfo[1].dayppcp+','+objWeatherInfo.dailyInfo[2].dayppcp+','+objWeatherInfo.dailyInfo[3].dayppcp+','+objWeatherInfo.dailyInfo[4].dayppcp+'&lows='+objWeatherInfo.dailyInfo[0].lowTemp+','+objWeatherInfo.dailyInfo[1].lowTemp+','+objWeatherInfo.dailyInfo[2].lowTemp+','+objWeatherInfo.dailyInfo[3].lowTemp+','+objWeatherInfo.dailyInfo[4].lowTemp+'&highs='+objWeatherInfo.dailyInfo[0].highTemp+','+objWeatherInfo.dailyInfo[1].highTemp+','+objWeatherInfo.dailyInfo[2].highTemp+','+objWeatherInfo.dailyInfo[3].highTemp+','+objWeatherInfo.dailyInfo[4].highTemp+'&conditions='+objWeatherInfo.dailyInfo[0].daycond+','+objWeatherInfo.dailyInfo[1].daycond+','+objWeatherInfo.dailyInfo[2].daycond+','+objWeatherInfo.dailyInfo[3].daycond+','+objWeatherInfo.dailyInfo[4].daycond+'&codes='+objWeatherInfo.dailyInfo[0].dayicon+','+objWeatherInfo.dailyInfo[1].dayicon+','+objWeatherInfo.dailyInfo[2].dayicon+','+objWeatherInfo.dailyInfo[3].dayicon+','+objWeatherInfo.dailyInfo[4].dayicon+'&linkidx='+aryTWCLinks[objWeatherInfo.links[0].title]+','+aryTWCLinks[objWeatherInfo.links[1].title]+','+aryTWCLinks[objWeatherInfo.links[2].title]+','+aryTWCLinks[objWeatherInfo.links[3].title]+'&phases='+strPhases;    
  3289.         
  3290.         strParas = encodeURIComponent(strParas); 
  3291.         
  3292.         return strParas; 
  3293.     }
  3294.     
  3295.     
  3296.     function _displayExtendedWeather(dispMode, graphName)
  3297.     {
  3298.         var dispMode = (typeof dispMode == "undefined") ? 0 : dispMode; 
  3299.         var graphName = (typeof graphName == "undefined") ? "vapor" : graphName; 
  3300.         
  3301.         removeWeather(true, true);
  3302.         var doc = getCurDocument(); 
  3303.         var wnd = GetClientWindow(doc); 
  3304.         var shift = 64;
  3305.  
  3306.         toggleTopmostFlash(doc, false); 
  3307.         
  3308.         var rectClient = getClientRect(doc, wnd);         
  3309.         var divExtendedHolder = doc.getElementById(extendedHolderId); 
  3310.         if(divExtendedHolder)
  3311.         {
  3312.             divExtendedHolder.style.left = getPixel(0);
  3313.             divExtendedHolder.style.top = getPixel(0);
  3314.         }
  3315.         else
  3316.         {
  3317.             divExtendedHolder = doc.createElement("div");
  3318.             divExtendedHolder.style.padding="0px";
  3319.             divExtendedHolder.style.margin="0px"; 
  3320.             divExtendedHolder.style.border = "none"; 
  3321.             divExtendedHolder.style.backgroundColor="transparent";
  3322.             divExtendedHolder.style.left = getPixel(0);
  3323.             divExtendedHolder.style.top = getPixel(0);
  3324.             divExtendedHolder.style.width = (rectClient.width) + "px";
  3325.             divExtendedHolder.style.height = (rectClient.height) + "px";
  3326.             divExtendedHolder.style.display = "block";
  3327.             divExtendedHolder.style.position = (browserType == BROWSER_IE) ? "absolute" : "fixed";
  3328.             divExtendedHolder.id = extendedHolderId;            
  3329.  
  3330.             var divExtendedCanvas = doc.createElement("div");
  3331.             divExtendedCanvas.style.border = "1px solid #0B48A4"; 
  3332.             divExtendedCanvas.style.backgroundColor=fadingColor; 
  3333.             divExtendedCanvas.style.padding="0px";
  3334.             divExtendedCanvas.style.margin="0px"; 
  3335.             divExtendedCanvas.style.position = "absolute";
  3336.             divExtendedCanvas.style.display = "block";
  3337.             divExtendedCanvas.style.left = getPixel(0); 
  3338.             divExtendedCanvas.style.top = getPixel(0); 
  3339.             divExtendedCanvas.style.width = rectClient.width +"px";
  3340.             divExtendedCanvas.style.height = rectClient.height + "px";
  3341.             divExtendedCanvas.style.zIndex = "9999";
  3342.             divExtendedCanvas.id = extendedWeatherCanvasId;
  3343.             setOpacity(divExtendedCanvas.style, fadingRatio); 
  3344.  
  3345.             divExtendedWeather = doc.createElement("div");
  3346.             divExtendedWeather.style.border = "none"; 
  3347.             divExtendedWeather.style.backgroundColor="transparent";
  3348.             divExtendedWeather.style.position = "absolute";
  3349.             divExtendedWeather.style.display = "block";
  3350.             
  3351.             var strSwitch = '';
  3352.             
  3353.             if(dispMode == 0)
  3354.             {
  3355.                 /*
  3356.                 divExtendedWeather.style.left = getPixel((rectClient.width - extendedWidth) / 2); 
  3357.                 divExtendedWeather.style.top = getPixel((rectClient.height - extendedHeight) / 2 - shift); 
  3358.                 divExtendedWeather.style.width = extendedWidth +"px";
  3359.                 divExtendedWeather.style.height = extendedHeight + "px";        
  3360.                 */
  3361.                 var deltaH = (rectClient.height - extendedHeight) / 2;                
  3362.                 divExtendedWeather.style.width = (rectClient.width) +"px";
  3363.                 divExtendedWeather.style.height = (extendedHeight + deltaH - shift) + "px";        
  3364.                 divExtendedWeather.style.left = "0px"; 
  3365.                 divExtendedWeather.style.top = "0px"; // getPixel((rectClient.height - CANVAS_HEIGHT) / 2 - shift); 
  3366.                                 
  3367.                 
  3368.                 strSwitch = '<a class="st-taf" href="javascript:;" style="border:0;padding:0;margin:0;"><img id="aniWeatherGraphic" title="Graphic Reports" style="border:0;padding:0;margin:0 32px 0 0;display:inline;" width="64" height="64" src="'+weatherMediaBase+'res/radarmap.png" /></a>'; 
  3369.             }
  3370.             else
  3371.             {    
  3372.                 var deltaH = (rectClient.height - CANVAS_HEIGHT) / 2;
  3373.                 
  3374.                 divExtendedWeather.style.width = (rectClient.width) +"px";
  3375.                 divExtendedWeather.style.height = (CANVAS_HEIGHT + deltaH - shift) + "px";        
  3376.                 divExtendedWeather.style.left = "0px"; 
  3377.                 divExtendedWeather.style.top = "0px"; // getPixel((rectClient.height - CANVAS_HEIGHT) / 2 - shift); 
  3378.                 
  3379.                 strSwitch = '<a class="st-taf" href="javascript:;" style="border:0;padding:0;margin:0;"><img id="aniWeatherAnimated" title="Animated 5-Day Forecast" style="border:0;padding:0;margin:0 32px 0 0;display:inline;" width="64" height="64" src="'+weatherMediaBase+'res/animated.png" /></a>'; 
  3380.                 
  3381.             }    
  3382.             
  3383.             divExtendedWeather.style.zIndex = "10000";
  3384.             divExtendedWeather.id = extendedWeatherId;            
  3385.  
  3386.             var strParas = weatherHelperString; 
  3387.             if(browserType == BROWSER_FF)
  3388.                  strParas = _attachLocIds(strParas); 
  3389.             
  3390.             var aryParas = strParas.split('&'); 
  3391.             var len  = aryParas.length; 
  3392.             
  3393.             var aryCities = [];
  3394.             var aryLocIds = [];
  3395.             var strVal;
  3396.             for(var i=len-1;i>=0;i--)
  3397.             {
  3398.                 strVal = aryParas[i];
  3399.                 var pos = strVal.indexOf('cities=');
  3400.                 if(pos >= 0)
  3401.                 {
  3402.                     strVal = strVal.substr(7); 
  3403.                     aryCities = strVal.split('|'); 
  3404.                 }
  3405.                 
  3406.                 strVal = aryParas[i];
  3407.                 var pos = strVal.indexOf('locids=');
  3408.                 if(pos >= 0)
  3409.                 {
  3410.                     strVal = strVal.substr(7); 
  3411.                     aryLocIds = strVal.split('|'); 
  3412.                 }                
  3413.             }    
  3414.             
  3415.             len = Math.min(aryCities.length, aryLocIds.length); 
  3416.             if(extendedWidth < 480)
  3417.                 len = 2; 
  3418.             var strMoreCities = "";
  3419.             for(var i=0;i<len;i++)
  3420.             {
  3421.                 var city = aryCities[i];
  3422.                 var pos = city.indexOf(','); 
  3423.                 if(pos > 0)
  3424.                     city = city.substr(0, pos); 
  3425.                 strMoreCities += '<a style="font-family: Verdana, Arial, Helvetica, sans-serif; font-weight:bold; font-size:12px; color:#ffffff; margin:8px;" href="javascript:;" id="'+weatherCityLinkId+''+aryLocIds[i]+ '" >' +city+'</a>';  
  3426.             }
  3427.             
  3428.             var strRecomm = '';
  3429.             if(browserType == BROWSER_FF)
  3430.             {
  3431.                 strRecomm = '<a class="st-taf" href="javascript:;" onclick="return false;" style="border:0;padding:0;margin:0;"><img title="Tell your friends about AniWeather" style="border:0;padding:0;margin:0;display:inline;" width="64" height="64" src="'+weatherMediaBase+'res/share.png" onmouseout="STTAFFUNC.hideHoverMap(this)" onmouseover="STTAFFUNC.showHoverMap(this, \'2009053018259\', \'http://www.aniweather.com\', \'AniWeather: Animated Weather + Any Weather\')" onclick="STTAFFUNC.cw(this, {id:\'2009053018259\', link: \'http://www.aniweather.com\', title: \'AniWeather: Animated Weather + Any Weather\' });"/></a>'; 
  3432.             }
  3433.             else if(browserType == BROWSER_CHROME)
  3434.             {
  3435.                 strRecomm = '<a class="st-taf" href="http://www.aniweather.com/?sr=1'+'" target="_blank" style="border:0;padding:0;margin:0;"><img title="Tell your friends about AniWeather" style="border:0;padding:0;margin:0;display:inline;" width="64" height="64" src="'+weatherMediaBase+'res/share.png"  /></a>'; 
  3436.             }
  3437.             
  3438.             var closeLeft;
  3439.             var closeTop;
  3440.             var closeSize = 32;
  3441.             
  3442.             /*
  3443.             if(dispMode == 0)
  3444.             {
  3445.                 var closeSize = 32;
  3446.                 closeSize = closeSize*extendedWidth/640; 
  3447.                 
  3448.                 closeLeft = rectClient.width-closeSize-4; 
  3449.                 closeTop = (displayMode == 0) ? 28 : 10; 
  3450.                 closeTop = closeTop*extendedWidth/640;
  3451.             }
  3452.             else
  3453.             {
  3454.             */
  3455.             
  3456.             var fileName = (displayMode == 0) ? 'weather7.swf' : 'weather3.swf'; 
  3457.             var strWeatherContent = (dispMode == 0) ? 
  3458.                 //. '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+extendedWidth+'" height="'+extendedHeight+'"><param name="movie" value="'+weatherMediaBase+'media/'+fileName+'" /><param name="FlashVars" value="'+strParas+'" /><param name="wmode" value="transparent"><param name="quality" value="high" /><embed src="'+weatherMediaBase+'media/'+fileName+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="'+strParas+'" type="application/x-shockwave-flash" width="'+extendedWidth+'" height="'+extendedHeight+'" wmode="transparent"></embed></object>' : 
  3459.                 '<iframe type="content" style="width:100%; height:100%;border:none; visibility:hidden" id="frmWeatherContent" scrolling="no" allowtransparency="true" src="'+weatherSiteBase+'showaw2.html?width='+extendedWidth+'&ch='+parseInt(divExtendedWeather.style.height)+'&p='+strParas+'" ></iframe>' :                 
  3460.                 '<iframe type="content" style="width:100%; height:100%;border:none; visibility:hidden" id="frmGraphContent" scrolling="no" allowtransparency="true" src="'+weatherSiteBase+'noaa/noaa_index.html?height='+parseInt(divExtendedWeather.style.height)+'&ani=0&graph='+graphName+'" ></iframe>'; 
  3461.                 
  3462.             // closeSize = closeSize*extendedWidth/640; 
  3463.             closeLeft = (rectClient.height > doc.body.offsetHeight) ? rectClient.width-closeSize-4 : rectClient.width-closeSize-20; 
  3464.             closeTop = 4;
  3465.             
  3466.             
  3467.             divExtendedWeather.innerHTML = '<div style="display:block; position:fixed; left:0px; top:0px; padding:4px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold;"><a style="text-decoration:none; color:#ffffff;" href="http://www.aniweather.com/" target="_blank"><img align="absmiddle" id="aniweatherLogo" style="border:0px; padding:0px; margin:0px; cursor:pointer; " width="32" height="32" src="'+weatherMediaBase+'res/aniweather_logo_32.png" > AniWeather</a></div><img id="aniweatherExtendedClose" style="border:0px; padding:0px; margin:0px; cursor:pointer;display:block; position:fixed; left:'+closeLeft+'px; top:'+closeTop+'px;" width="'+closeSize+'" height="'+closeSize+'" src="'+weatherMediaBase+'res/big_close.png" >'+strWeatherContent+'<br /><div align="center" style="padding:0px;margin:0px;">'+strMoreCities+'</div><div id="'+weatherDashboardId+'" style="padding-top:16px;" align="center"><script type="text/javascript" src="http://cdn.socialtwist.com/2009053018259/script.js"></script><a class="st-taf" href="'+weatherSiteBase+''+ 'locale/' + localeId +'/' + settingPageName + '#settings" target="_blank" style="border:0;padding:0;margin:0;"><img title="Settings" style="border:0;padding:0;margin:0 32px 0 32px;display:inline;" width="64" height="64" src="'+weatherMediaBase+'res/setting.png" /></a>'+strRecomm+'<a class="st-taf" href="'+weatherSiteBase+''+feedbackPageName+'" style="border:0;padding:0;margin:0;" target="_blank"><img title="Feedback" style="border:0;padding:0;margin:0 32px 0 32px;display:inline;" width="64" height="64" src="'+weatherMediaBase+'res/feedback.png" /></a>'+strSwitch+'</div>'; 
  3468.             
  3469.             divExtendedHolder.appendChild(divExtendedCanvas); 
  3470.             divExtendedHolder.appendChild(divExtendedWeather); 
  3471.             
  3472.             doc.body.appendChild(divExtendedHolder, false);    
  3473.             setEventListener(divExtendedHolder, 'click', onExtendedHolderClicked, false); 
  3474.             
  3475.             var objClose = doc.getElementById('aniweatherExtendedClose'); 
  3476.             setEventListener(objClose, 'click', onExtendedClose, false); 
  3477.             
  3478.             var objGraphic = doc.getElementById('aniWeatherGraphic'); 
  3479.             setEventListener(objGraphic, 'click', onAniWeatherGraphic, false); 
  3480.             
  3481.             var objAnimated = doc.getElementById('aniWeatherAnimated'); 
  3482.             setEventListener(objAnimated, 'click', onAniWeatherAnimated, false); 
  3483.             
  3484.             for(var i=0;i<len;i++)
  3485.             {
  3486.                 var strId = weatherCityLinkId+aryLocIds[i];
  3487.                 var objCity = doc.getElementById(strId);
  3488.                 if(objCity)
  3489.                     setEventListener(objCity, 'click', onCityRequest, false); 
  3490.             }        
  3491.  
  3492.             if(browserType == BROWSER_FF)
  3493.             {
  3494.                 var appcontent = document.getElementById("appcontent");   // browser
  3495.                 if(appcontent)
  3496.                 {
  3497.                     setEventListener(appcontent, 'keydown', smartKeyPress, false);
  3498.                 }
  3499.             }
  3500.             else if(browserType == BROWSER_CHROME)
  3501.             {
  3502.                 setEventListener(doc, 'keydown', smartKeyPress, false);
  3503.             }
  3504.             
  3505.             var objFrame = doc.getElementById(dispMode == 0 ? 'frmWeatherContent' : 'frmGraphContent'); 
  3506.             if(objFrame)
  3507.                 setTimeout(function(){objFrame.style.visibility = "visible"; }, 500); 
  3508.         }        
  3509.         
  3510.         function onAniWeatherGraphic(event)
  3511.         {
  3512.             _displayExtendedWeather(1);
  3513.         }
  3514.         
  3515.         function onAniWeatherAnimated(event)
  3516.         {
  3517.             _displayExtendedWeather(0);
  3518.         }    
  3519.  
  3520.         function onExtendedClose(event)
  3521.         {
  3522.             var doc = getDocumentByEvent(event); 
  3523.             var obj = getObjectByEvent(event); 
  3524.             
  3525.             if(obj && obj.id == "aniweatherExtendedClose")
  3526.             {
  3527.                 removeWeather(true, true); 
  3528.                 toggleTopmostFlash(doc, true); 
  3529.             }
  3530.         }
  3531.         
  3532.         function onCityRequest(event)
  3533.         {
  3534.             var doc = getDocumentByEvent(event); 
  3535.             var obj = getObjectByEvent(event); 
  3536.             
  3537.             var strId =  obj.id;
  3538.             var pos = strId.indexOf(weatherCityLinkId);
  3539.             if(pos == 0)
  3540.             {
  3541.                 var locid = strId.substr(weatherCityLinkId.length); 
  3542.                 
  3543.                 if(browserType == BROWSER_CHROME)
  3544.                 {
  3545.                     if(curPort)
  3546.                         curPort.postMessage({'purpose':'getweather', 'id':locid}); 
  3547.                 }    
  3548.                 else
  3549.                     _getWeatherDetails(false, true, null, locid); 
  3550.             }        
  3551.         }
  3552.         
  3553.         function toggleTopmostFlash(doc, display)
  3554.         {
  3555.             aryFlash = doc.getElementsByTagName('object'); 
  3556.             var len = aryFlash.length; 
  3557.             for(var i=0;i<len;i++)
  3558.             {
  3559.                 var objFlash = aryFlash[i];
  3560.                 objFlash.style.visibility = display ? "visible" : "hidden"; 
  3561.             }
  3562.             
  3563.             aryFlash = doc.getElementsByTagName('embed'); 
  3564.             var len = aryFlash.length; 
  3565.             for(var i=0;i<len;i++)
  3566.             {
  3567.                 var objFlash = aryFlash[i];
  3568.                 objFlash.style.visibility = display ? "visible" : "hidden"; 
  3569.             }            
  3570.         }
  3571.         
  3572.         function getObjectByEvent(event)
  3573.         {
  3574.             if(browserType == BROWSER_IE)
  3575.             {
  3576.                 var objtype = typeof event.srcElement;
  3577.                 if(objtype.toLowerCase() != "unknown")
  3578.                     return event.srcElement;
  3579.                 else
  3580.                     return null; 
  3581.               }
  3582.             else if(browserType == BROWSER_FF)
  3583.                 return event.originalTarget;
  3584.             else if(browserType == BROWSER_CHROME)
  3585.                 return event.srcElement;
  3586.         }
  3587.         
  3588.         function onExtendedHolderClicked(event)
  3589.         {
  3590.             var x = event.clientX; 
  3591.             var y = event.clientY; 
  3592.             
  3593.             var doc = getCurDocument(); 
  3594.             var obj = getObjectByEvent(event); 
  3595.             var escape = false;
  3596.             while(true)
  3597.             {
  3598.                 if(obj.id && obj.id == extendedWeatherId)
  3599.                 {
  3600.                     escape = true; 
  3601.                     break;
  3602.                 }
  3603.                 
  3604.                 if(obj.parentNode)
  3605.                     obj = obj.parentNode;
  3606.                 else
  3607.                     break;
  3608.             }            
  3609.             
  3610.             if(!escape)
  3611.             {
  3612.                 removeWeather(true, true); 
  3613.                 toggleTopmostFlash(doc, true); 
  3614.             }
  3615.         }
  3616.     }
  3617.     
  3618.     
  3619.     this.displayExtendedWeather = function(data, mode, graphName)
  3620.     {
  3621.         var mode = (typeof mode == "undefined") ? 0 : mode;
  3622.         
  3623.         if(data != null)
  3624.             weatherHelperString = data;  
  3625.             
  3626.         _displayExtendedWeather(mode, graphName); 
  3627.     }
  3628.  
  3629.     function onDisplayExtendedWeather(event)
  3630.     {
  3631.         _displayExtendedWeather(); 
  3632.     }
  3633.     
  3634.     function onMoreGraph(event)
  3635.     {
  3636.         _displayExtendedWeather(1, currentGraphId); 
  3637.     }
  3638.     
  3639.     function resetLauncher()
  3640.     {
  3641.         removeLauncher(docLauncher); 
  3642.         docLauncher = null;    
  3643.  
  3644.         launcherIdx = 0; 
  3645.         currentReportId = "";
  3646.  
  3647.         if(tmLauncherAnimation)
  3648.         {
  3649.             clearInterval(tmLauncherAnimation); 
  3650.             tmLauncherAnimation = null; 
  3651.         }
  3652.     }
  3653.     
  3654.     function removeLauncher(doc)
  3655.     {
  3656.         if(doc)
  3657.         {
  3658.             var objLauncher = doc.getElementById(weatherLauncherId); 
  3659.             if(objLauncher)
  3660.                 doc.body.removeChild(objLauncher); 
  3661.         }        
  3662.     }
  3663.     
  3664.     function displayLauncher(doc, data, info, ani, force, anchor)
  3665.     {
  3666.         if(typeof doc.body == "undefined")
  3667.             return; 
  3668.         
  3669.         if(doc.defaultView.innerWidth < MIN_LAUNCHER_WIDTH || doc.defaultView.innerHeight < MIN_LAUNCHER_HEIGHT)    
  3670.             return; 
  3671.             
  3672.         //. Image
  3673.         if (!doc.body.hasChildNodes() || (doc.body.childNodes.length == 1 && doc.body.childNodes[0].nodeName.toLowerCase() == "img"))
  3674.         {
  3675.             return; 
  3676.         }
  3677.         
  3678.         var isGraphic = (currentReportId != "" && typeof lstReportId[currentReportId] == "undefined"); 
  3679.         
  3680.         
  3681.         if(isGraphic)
  3682.             currentGraphId = currentReportId; 
  3683.         
  3684.         var force = force ? force : false; 
  3685.         
  3686.         if(doc != docLauncher || force)
  3687.             //. remove the launcher in other doc
  3688.             resetLauncher(); 
  3689.             
  3690.         var ani = isGraphic ? false : (ani ? ani : false); 
  3691.         var info = (typeof info == "undefined") ? null : info; 
  3692.         
  3693.         var objLauncher = doc.getElementById(weatherLauncherId); 
  3694.         var objExtended = doc.getElementById(extendedHolderId); 
  3695.         if(objLauncher || objExtended)
  3696.             return; 
  3697.  
  3698.         var wnd = GetClientWindow(doc); 
  3699.         var rectClient = getClientRect(doc, wnd);         
  3700.         var launcherMargin = (browserType == BROWSER_FF) ? 12 : 24;
  3701.  
  3702.         if(data && data.length > 0)
  3703.         {
  3704.             weatherHelperString = data;  
  3705.         }    
  3706.         else
  3707.             weatherHelperString = weatherDefaultString;
  3708.         
  3709.         var bLargeNotice = (!isGraphic && info != null && info.dayname.toLowerCase() != "now");
  3710.         var bkImg;
  3711.         var noticeH;
  3712.         if(bLargeNotice){
  3713.             bkImg = 'noticebkl2.png';
  3714.             noticeH = noticeMoreHeight;
  3715.         }
  3716.         else{
  3717.             bkImg = 'noticebk4.png';
  3718.             noticeH = noticeHeight;
  3719.         }
  3720.  
  3721.         var launcherWidth = isGraphic ? objConfigPara.graphPreviewWidth : noticeWidth; 
  3722.         var launcherHeight = isGraphic ? Math.floor(objConfigPara.graphPreviewWidth * defaultGraphHeight / defaultGraphWidth): noticeH; 
  3723.         
  3724.         var shift = ani ? launcherHeight/2 - 16 : launcherHeight; 
  3725.         var launcherLeft = 4;
  3726.         var scrollWidth = (rectClient.height > doc.body.offsetHeight) ? 12 : 28; 
  3727.         
  3728.         if(typeof anchor == "undefined")
  3729.         {
  3730.             // if(browserType == BROWSER_FF)
  3731.                 launcherLeft = rectClient.width - launcherWidth - scrollWidth;
  3732.             // else if(browserType == BROWSER_CHROME)        
  3733.             //     launcherLeft = launcherMargin;
  3734.         }    
  3735.         else
  3736.             launcherLeft = Math.min(rectClient.width - launcherWidth - scrollWidth, Math.max(0, anchor - launcherWidth/2 - scrollWidth)); 
  3737.  
  3738.         var divWeatherLauncher = doc.createElement("div");
  3739.         divWeatherLauncher.style.border = "none"; 
  3740.         
  3741.         if(isGraphic)
  3742.         {
  3743.             divWeatherLauncher.style.backgroundColor = "#222222";
  3744.             divWeatherLauncher.style.padding = "0px"
  3745.             divWeatherLauncher.style.border = "solid 1px #888888";
  3746.             divWeatherLauncher.style.color = "#ffffff"; 
  3747.             divWeatherLauncher.style.fontWeight = "bold"; 
  3748.             divWeatherLauncher.style.fondSize = "10px"; 
  3749.             
  3750.         }
  3751.         else
  3752.         {
  3753.             divWeatherLauncher.style.background= "url("+weatherMediaBase+"res/"+bkImg+") top left no-repeat";
  3754.             divWeatherLauncher.style.backgroundColor = "transparent";
  3755.             divWeatherLauncher.style.padding = "8px";
  3756.             divWeatherLauncher.style.border = "none";
  3757.         }
  3758.         
  3759.         var holderId = getCharPref('displayPosition'); 
  3760.         var atBottom = (holderId == "status-bar") || ani || (browserType == BROWSER_CHROME);
  3761.  
  3762.         divWeatherLauncher.style.position = "fixed";
  3763.         divWeatherLauncher.style.border = "none";
  3764.         divWeatherLauncher.style.margin = "0"; 
  3765.         divWeatherLauncher.style.display = "block";
  3766.         divWeatherLauncher.style.left = getPixel(launcherLeft); 
  3767.         divWeatherLauncher.style.top = atBottom ? getPixel(rectClient.height - shift - launcherMargin) : "4px"; 
  3768.         divWeatherLauncher.style.width = launcherWidth +"px";
  3769.         divWeatherLauncher.style.height = launcherHeight + "px";    
  3770.         divWeatherLauncher.style.zIndex = "9999";        
  3771.         // divWeatherLauncher.style.cursor = "pointer"; 
  3772.         divWeatherLauncher.style.fontFamily = "Verdana, Arial, Helvetica, sans-serif";
  3773.         divWeatherLauncher.id = weatherLauncherId;    
  3774.         
  3775.         var uv = '';
  3776.         var ppcp = '';
  3777.  
  3778.         
  3779.         if(!isGraphic)
  3780.         {
  3781.             if(info == null)
  3782.             {
  3783.                 // Get current condition
  3784.                 info = new  AniWeatherObj.GeneralWeather(); 
  3785.  
  3786.                 var strParas = decodeURIComponent(weatherHelperString);
  3787.                 var aryData = strParas.split('&'); 
  3788.                 
  3789.                 info.dayname = "Now"; 
  3790.                 info.locname = aryData[0].split('=')[1];
  3791.                 var temp = aryData[3].split('=')[1];
  3792.                 info.cond = aryData[4].split('=')[1];
  3793.                 info.windcond = aryData[5].split('=')[1];
  3794.                 info.icon = aryData[6].split('=')[1];
  3795.                 var units = aryData[7].split('=')[1];
  3796.                 info.tempval = getTempValue(temp, parseInt(units.split(',')[0]));
  3797.                 info.vis = aryData[8].split('=')[1];
  3798.                 info.humid = aryData[9].split('=')[1];
  3799.                 info.uv = aryData[10].split('=')[1];    
  3800.                 info.ppcp = ""; // aryData[11].split('=')[1];    
  3801.                 
  3802.                 var  len = aryData.length;
  3803.                 for(var i=0;i<len;i++)
  3804.                 {
  3805.                     var aryVal = aryData[i].split('=');
  3806.                     if(aryVal[0].toLowerCase() == "phases")
  3807.                     {
  3808.                         info.moonphase = aryVal[1].split(',')[0];
  3809.                     }
  3810.                 }
  3811.             }
  3812.  
  3813.             if(info.uv != '')
  3814.                 uv = "<br />" + getLocaleString('display.uv') + ": " + info.uv;
  3815.             if(info.ppcp != '')
  3816.                 ppcp = "<br />" + getLocaleString('display.pop') + ": " + info.ppcp;         
  3817.         }
  3818.  
  3819.         var strDayObj;
  3820.         var strNightObj;
  3821.         
  3822.         if(info.useMiniFrame == 0)
  3823.         {
  3824.             var fileName = "weather5s.swf"; 
  3825.             var params = "nowicon="+info.icon+"&phase="+info.moonphase;
  3826.             var width = bLargeNotice ? traySmallWidth : trayWidth; 
  3827.             var height = trayHeight * width / trayWidth;
  3828.             
  3829.             if(bLargeNotice)
  3830.             {
  3831.                 strDayObj = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'"><param name="movie" value="'+weatherMediaBase+'media/'+fileName+'" /><param name="FlashVars" value="'+params+'" /><param name="wmode" value="transparent"><param name="quality" value="high" /><embed src="'+weatherMediaBase+'media/'+fileName+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="'+params+'" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" wmode="transparent"></embed></object>'; 
  3832.                 
  3833.                 params = "nowicon="+info.nighticon+"&phase="+info.moonphase;
  3834.                 strNightObj = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'"><param name="movie" value="'+weatherMediaBase+'media/'+fileName+'" /><param name="FlashVars" value="'+params+'" /><param name="wmode" value="transparent"><param name="quality" value="high" /><embed src="'+weatherMediaBase+'media/'+fileName+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="'+params+'" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" wmode="transparent"></embed></object>';                 
  3835.             }
  3836.             else
  3837.                 strDayObj = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'"><param name="movie" value="'+weatherMediaBase+'media/'+fileName+'" /><param name="FlashVars" value="'+params+'" /><param name="wmode" value="transparent"><param name="quality" value="high" /><embed src="'+weatherMediaBase+'media/'+fileName+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="'+params+'" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" wmode="transparent"></embed></object>';             
  3838.         }
  3839.         else
  3840.         {
  3841.             if(bLargeNotice)
  3842.             {
  3843.                 strDayObj = '<iframe type="content" style="width:100%; height:100%;border:none;padding:0; margin:0;" id="frmWeatherContent" scrolling="no" allowtransparency="true" src="'+weatherSiteBase+'showmini.html?width='+traySmallWidth+'&icon='+info.icon+'&phase='+info.moonphase+'" ></iframe>'; 
  3844.                 strNightObj = '<iframe type="content" style="width:100%; height:100%;border:none;padding:0; margin:0;" id="frmWeatherContent" scrolling="no" allowtransparency="true" src="'+weatherSiteBase+'showmini.html?width='+traySmallWidth+'&icon='+info.nighticon+'&phase='+info.moonphase+'" ></iframe>';                 
  3845.             }
  3846.             else
  3847.                 strDayObj = '<iframe type="content" style="width:100%; height:100%;border:none;padding:0; margin:0;" id="frmWeatherContent" scrolling="no" allowtransparency="true" src="'+weatherSiteBase+'showmini.html?width='+trayWidth+'&icon='+info.icon+'&phase='+info.moonphase+'" ></iframe>';         
  3848.         }
  3849.         
  3850.         var content = "";
  3851.         if(isGraphic)
  3852.         {
  3853.             var strCtrls = "";
  3854.             if(false && browserType != BROWSER_FF)
  3855.                 strCtrls = ' <a style="color:#ffffff; font-size:12px;font-weight:bold;" href="javascript:;" id="moreAniWeatherGraph">More</a>  <a style="color:#ffffff; font-size:12px;font-weight:bold;" href="javascript:;" id="aniweatherLauncherClose">Close</a>'; 
  3856.                 
  3857.             content = '<div style="padding:0; margin:0; width:100%; height:'+(launcherHeight-20)+'px;" ><iframe type="content" style="border:none; width:100%; height:100%; padding:0; margin:0;" id="frmGraphContent" scrolling="no" allowtransparency="true" src="'+weatherSiteBase+'noaa/graph.html?type='+info.graphId+'&ani='+info.graphAnimation+'&thumb=1&width='+objConfigPara.graphPreviewWidth+'" ></iframe></div><div style="position:absolute;left:0px;top:0px;display:block;width:100%;height:'+(launcherHeight-20)+'px;background-color:transparent;cursor:pointer; border:none;" id="divGraphMask"></div><div align="right" style="margin:0; padding:0; border:none;"><span style="font-size:12px; color:#ffff00;">'+info.graphDesc+'</span> ' +strCtrls+ '</div>'; 
  3858.         }
  3859.         else if(bLargeNotice)
  3860.         {
  3861.             content = '<div id="'+ weatherLauncherHolderId + '" style="display:block;position:absolute; top:4px; left:0px; width:'+noticeWidth+'px; cursor:pointer; "><div style="border:none; display:block; position:absolute;left:4px;top:-4px;width:'+traySmallWidth+'px;height:'+traySmallHeight+'px;padding:0px;margin:0px;background-color:transparent;">'+strDayObj+'</div><div style="border:none; display:block; position:absolute;left:4px;top:88px;width:'+traySmallWidth+'px;height:'+traySmallHeight+'px;padding:0px;margin:0px;background-color:transparent;">'+strNightObj+'</div><div style="position:absolute;display:block; left:8px;top:'+(launcherHeight-32)+'px;font-size:12px; border:none; font-weight:bold; color:#ffff33; padding:0px;margin:0px;margin-bottom:2px; "><span id="regionLocName" style="border:none;margin:0;padding:0;">'+info.locname+'</span><span style="color:#22ff22;margin:0px;padding:0px;">  '+FULLWEEKDAY[info.dayname]+'</span></div><div align="left" style="display:block; font-weight:normal; position:absolute;left:'+(traySmallWidth+8)+'px;margin-right:0px;top:8px;width:'+(noticeWidth-traySmallWidth)+'px;height:'+(traySmallHeight-8)+'px;line-height:1.2em; padding:0px;margin:0px;color:#ffffff;font-size:11px;border:none; "><span style="color:#22ff22;margin:0px;padding:0px;"><strong style="color:#22ff22;">'+info.daypart+' </strong>'+info.tempval+'</span><br />'+info.cond+'<br />'+info.windcond+'<br />' + getLocaleString('display.humidity') + ': '+info.humid+uv+ppcp+'<br />' + getLocaleString('display.sunrise') + ': '+info.sunrise+'</div><div align="left" style="display:block; font-weight:normal; position:absolute;left:'+(traySmallWidth+8)+'px;margin-right:0px;top:96px;width:'+(noticeWidth-traySmallWidth)+'px;height:'+(traySmallHeight-8)+'px;line-height:1.2em; padding:0px;margin:0px;color:#ffffff;font-size:11px;border:none; "><span style="color:#22ff22;margin:0px;padding:0px;"><strong style="color:#22ff22;">' + getLocaleString('display.night') + ' </strong>'+info.nighttemp+'</span><br />'+info.nightcond+'<br />'+info.nightwindcond+'<br />' + getLocaleString('display.humidity') + ': '+info.nighthumid+'<br />' + getLocaleString('display.pop') + ': '+info.nightppcp+'<br />' + getLocaleString('display.sunset') + ': '+info.sunset+'</div>';     
  3862.         }
  3863.         else
  3864.         {
  3865.             content = '<div id="'+ weatherLauncherHolderId + '" style="display:block;position:absolute; top:4px; left:0px; width:'+noticeWidth+'px; cursor:pointer;"><div style="border:none; display:block; position:absolute;left:-12px;top:-24px;width:'+trayWidth+'px;height:'+trayHeight+'px;padding:0px;margin:0px;background-color:transparent;">'+strDayObj+'</div><div style="position:absolute;display:block; left:8px;top:'+(trayHeight-44)+'px;font-size:12px; border:none; font-weight:bold; color:#ffff33; padding:0px;margin:0px;margin-bottom:2px; "><span id="regionLocName" style="border:none;margin:0;padding:0;">'+info.locname+'</span><span style="color:#22ff22;margin:0px;padding:0px;">  '+FULLWEEKDAY[info.dayname]+', '+info.tempval+'</span></div><div align="left" style="display:block; font-weight:normal; position:absolute;left:'+(trayWidth-12)+'px;margin-right:0px;top:4px;width:'+(noticeWidth-trayWidth)+'px;height:'+noticeHeight+'px;line-height:1.2em; padding:0px;margin:0px;color:#ffffff;font-size:11px;">'+info.cond+'<br />'+info.windcond+'<br />' + getLocaleString('display.humidity') + ': '+info.humid+uv+ppcp+'</div>'; 
  3866.         
  3867.         }
  3868.  
  3869.  
  3870.         divWeatherLauncher.innerHTML = content;
  3871.                         
  3872.         doc.body.appendChild(divWeatherLauncher);     
  3873.         
  3874.         var locname = info.locname;
  3875.         var divLoc = doc.getElementById('regionLocName'); 
  3876.         if(divLoc)
  3877.         {
  3878.             var len = locname.length; 
  3879.             while(len > 10 && (divLoc.offsetWidth >= launcherWidth - 100 || divLoc.offsetHeight >= 20) )
  3880.             {
  3881.                 locname = locname.substr(0, len-1);
  3882.                 len--;
  3883.                 divLoc.innerHTML = locname + ".."; 
  3884.             }
  3885.         }
  3886.         
  3887.         var objLauncher = doc.getElementById(weatherLauncherHolderId); 
  3888.         setEventListener(objLauncher, 'click', onDisplayExtendedWeather, false); 
  3889.         setEventListener(objLauncher, 'mousemove', onLauncherMove, false); 
  3890.  
  3891.         var objClose = doc.getElementById("aniweatherLauncherClose"); 
  3892.         setEventListener(objClose, 'click', resetLauncher, false); 
  3893.  
  3894.         var objMore = doc.getElementById("aniweatherLauncherMore"); 
  3895.         setEventListener(objMore, 'click', onDisplayExtendedWeather, false); 
  3896.  
  3897.         var objGraph = doc.getElementById("moreAniWeatherGraph"); 
  3898.         setEventListener(objGraph, 'click', onMoreGraph, false); 
  3899.         
  3900.         var objMask = doc.getElementById("divGraphMask"); 
  3901.         setEventListener(objMask, 'click', onMoreGraph, false); 
  3902.         
  3903.         if(ani)
  3904.             tmLauncherAnimation = setInterval(animateLauncher, 100); 
  3905.         
  3906.         if(tmLauncher)
  3907.             clearTimeout(tmLauncher); 
  3908.     
  3909.         if(ani) // || browserType != BROWSER_FF)
  3910.             tmLauncher = setTimeout(resetLauncher, isGraphic ? graphTime : noticeTime); 
  3911.         
  3912.         docLauncher = doc; 
  3913.     }
  3914.  
  3915.     function _checkWeatherTimer(directReport)
  3916.     {
  3917.         var reportMode;
  3918.         if(typeof directReport == "boolean")
  3919.             reportMode = directReport ? 0 : 1; 
  3920.         else
  3921.             reportMode = 2; 
  3922.         
  3923.         if(reportMode == 2)
  3924.             checkIndex++; 
  3925.         else if(reportMode == 0)
  3926.             checkIndex = objConfigPara.noticeSpan;
  3927.                 
  3928.         _getWeatherDetails(false, false, null); 
  3929.  
  3930.         // schedule for next check up
  3931.         var now=new Date();
  3932.         var hour = now.getHours(); 
  3933.         var minute = now.getMinutes(); 
  3934.         
  3935.         //. Check at the beginning of each hour
  3936.         var moretime = (60-minute)*60000;  // 8000; // 
  3937.         
  3938.         // updateChromeStatus(now.getSeconds()); 
  3939.     
  3940.         setTimeout(_checkWeatherTimer, moretime); 
  3941.     }
  3942.     
  3943.     this.checkWeatherTimer = function(counting)
  3944.     {
  3945.         _checkWeatherTimer(counting); 
  3946.     }
  3947.     
  3948.     function onLauncherMove(event)
  3949.     {
  3950.         if(tmLauncher)
  3951.             clearTimeout(tmLauncher); 
  3952.         tmLauncher = setTimeout(resetLauncher, noticeTime); 
  3953.     }
  3954.     
  3955.     function animateLauncher(event)
  3956.     {
  3957.         var doc = getCurDocument(); 
  3958.         var objLauncher = doc.getElementById(weatherLauncherId); 
  3959.         var nowtop = parseInt(objLauncher.style.top);
  3960.         var move = launcherSpeed + launcherAcce * launcherIdx; 
  3961.         if(move <= 0)
  3962.         {
  3963.             launcherIdx = 0; 
  3964.             clearInterval(tmLauncherAnimation); 
  3965.             tmLauncherAnimation = null; 
  3966.         }    
  3967.         else 
  3968.         {
  3969.             objLauncher.style.top = getPixel(nowtop-move); 
  3970.             launcherIdx++;        
  3971.         }    
  3972.     }
  3973.     
  3974.     this.prepareReportById = function(reportId, anchor, disp)
  3975.     {
  3976.         var disp = (typeof disp == "undefined") ? true : disp; 
  3977.         var info = null; 
  3978.         
  3979.         var id = lstReportId[reportId];
  3980.         
  3981.         if(typeof id == "undefined")
  3982.         {
  3983.             var info = new  AniWeatherObj.GeneralWeather(); 
  3984.             info.graphId = reportId;
  3985.             info.graphDesc = aryGraphInfo[reportId].desc;
  3986.             info.graphAnimation = objConfigPara.graphLevel[reportId].animation;
  3987.             
  3988.             //. Graphic report, not daily report
  3989.             currentReportId = reportId; 
  3990.             
  3991.             if(disp)
  3992.                 displayLauncher(getCurDocument(), '', info, false, true, anchor); 
  3993.         }
  3994.         else
  3995.         {
  3996.             var info = new  AniWeatherObj.GeneralWeather(); 
  3997.             
  3998.             info.graphId = null; 
  3999.             
  4000.             // alert(objDefaultWeatherInfo.locationInfo.name); 
  4001.             info.locname = objDefaultWeatherInfo.locationInfo.name;
  4002.             info.cond = (id == 0) ? objDefaultWeatherInfo.currentInfo.condition : objDefaultWeatherInfo.dailyInfo[id-1].daycond;
  4003.  
  4004.             if(id == 1 && objDefaultWeatherInfo.passToday)
  4005.             {
  4006.                 info.tempval = objDefaultWeatherInfo.currentInfo.temp;            
  4007.                 info.daypart = getLocaleString('fullweekday.now'); 
  4008.             }
  4009.             else
  4010.             {
  4011.                 info.tempval = (id == 0) ? objDefaultWeatherInfo.currentInfo.temp : objDefaultWeatherInfo.dailyInfo[id-1].highTemp ;
  4012.                 info.daypart = getLocaleString('display.day'); 
  4013.             }
  4014.             info.tempval = getTempValue(info.tempval, objConfigPara.tempUnit); 
  4015.                 
  4016.             var windspeed = (id == 0) ? objDefaultWeatherInfo.currentInfo.windspeed : objDefaultWeatherInfo.dailyInfo[id-1].daywindspeed;
  4017.             windspeed = getWindValue(windspeed);
  4018.             
  4019.             var winddir = (id == 0) ? objDefaultWeatherInfo.currentInfo.winddir : objDefaultWeatherInfo.dailyInfo[id-1].daywinddir;
  4020.             info.windcond = getLocaleString('display.wind') + ": " + winddir + windspeed;
  4021.                     
  4022.             switch(id)
  4023.             {
  4024.                 case 0: 
  4025.                     info.dayname = "Now"; 
  4026.                     break;
  4027.                 case 1: 
  4028.                     info.dayname = "Today"; 
  4029.                     break;
  4030.                 default:
  4031.                     info.dayname = objDefaultWeatherInfo.dailyInfo[id-1].weekday;
  4032.             }
  4033.             
  4034.             info.icon = (id == 0) ? objDefaultWeatherInfo.currentInfo.icon : objDefaultWeatherInfo.dailyInfo[id-1].dayicon;
  4035.             info.vis = (id == 0) ? objDefaultWeatherInfo.currentInfo.visible : "";
  4036.             info.humid = (id == 0) ? objDefaultWeatherInfo.currentInfo.humid : objDefaultWeatherInfo.dailyInfo[id-1].dayhumid;
  4037.             info.uv =  (id == 0) ? objDefaultWeatherInfo.currentInfo.uvvalue +' ('+objDefaultWeatherInfo.currentInfo.uvlevel+')': "";
  4038.             info.ppcp = (id == 0) ? "" : objDefaultWeatherInfo.dailyInfo[id-1].dayppcp + "%";
  4039.             
  4040.             if(id > 0)
  4041.             {
  4042.                 info.sunrise = objDefaultWeatherInfo.dailyInfo[id-1].sunrise;
  4043.                 info.sunset = objDefaultWeatherInfo.dailyInfo[id-1].sunset;
  4044.                 info.nighticon = objDefaultWeatherInfo.dailyInfo[id-1].nighticon; 
  4045.                 info.nightcond = objDefaultWeatherInfo.dailyInfo[id-1].nightcond;
  4046.                 info.nighthumid = objDefaultWeatherInfo.dailyInfo[id-1].nighthumid;
  4047.                 info.nightppcp = objDefaultWeatherInfo.dailyInfo[id-1].nightppcp + "%";
  4048.                 info.nighttemp = getTempValue(objDefaultWeatherInfo.dailyInfo[id-1].lowTemp, objConfigPara.tempUnit); 
  4049.                 
  4050.                 windspeed = objDefaultWeatherInfo.dailyInfo[id-1].nightwindspeed;
  4051.                 windspeed = getWindValue(windspeed);
  4052.             
  4053.                 winddir = objDefaultWeatherInfo.dailyInfo[id-1].nightwinddir;
  4054.                 info.nightwindcond = getLocaleString('display.wind') + ": " + winddir + windspeed;
  4055.             }
  4056.             
  4057.             info.useMiniFrame = objConfigPara.useMiniFrame; 
  4058.             info.width = objConfigPara.weatherWidth; 
  4059.             info.height = objConfigPara.weatherHeight; 
  4060.             info.fadingRatio = objConfigPara.fadingRatio;
  4061.             info.fadingColor = objConfigPara.fadingColor;
  4062.             info.noticeSpan = objConfigPara.noticeSpan;
  4063.             info.displayMode = objConfigPara.displayMode;
  4064.             info.animate = false; 
  4065.             info.moonphase = parseInt(objDefaultWeatherInfo.currentInfo.moonicon) + ((id == 0) ? 0 : (id-1));
  4066.             if(info.moonphase >= 30)
  4067.                 info.moonphase -= 30; 
  4068.             
  4069.             displayMode = info.displayMode;
  4070.             extendedWidth = info.width;
  4071.             extendedHeight = DEFAULT_HEIGHT[displayMode]*info.width/DEFAULT_WIDTH;
  4072.             fadingRatio = info.fadingRatio;
  4073.             fadingColor = info.fadingColor;
  4074.             noticeSpan = info.noticeSpan;
  4075.             
  4076.             if(disp && (currentReportId != reportId))
  4077.             {            
  4078.                 currentReportId = reportId; 
  4079.                 displayLauncher(getCurDocument(), '', info, false, true, anchor); 
  4080.             }
  4081.         }
  4082.         
  4083.         return info; 
  4084.     }
  4085.     
  4086.     this.prepareReport = function(data, info, reportId, anchor, width)
  4087.     {
  4088.         var id = lstReportId[reportId];
  4089.         if(typeof id == "undefined")
  4090.         {
  4091.             //. Graphic report, not daily report
  4092.             currentReportId = reportId; 
  4093.             displayLauncher(getCurDocument(), data, info, false, true, anchor); 
  4094.         }    
  4095.         else if(currentReportId != reportId)
  4096.         {            
  4097.             currentReportId = reportId; 
  4098.             displayMode = info.displayMode;    
  4099.             extendedWidth = info.width;
  4100.             extendedHeight = DEFAULT_HEIGHT[displayMode]*info.width/DEFAULT_WIDTH;
  4101.             fadingRatio = info.fadingRatio;
  4102.             fadingColor = info.fadingColor;
  4103.             noticeSpan = info.noticeSpan;            
  4104.             
  4105.             if(browserType == BROWSER_CHROME)
  4106.                 objConfigPara.graphPreviewWidth = width; 
  4107.             displayLauncher(getCurDocument(), data, info, info.animate, true, anchor); 
  4108.         }    
  4109.         // displayLauncher(getCurDocument(), data); 
  4110.     }
  4111.     
  4112.     this.cancelReport = function(data)
  4113.     {
  4114.         removeLauncher(getCurDocument());
  4115.     }
  4116.  
  4117.     this.revokeReport = function()
  4118.     {
  4119.         resetLauncher();
  4120.     }
  4121.  
  4122.     function _displayTodayWeather()
  4123.     {
  4124.         //. TODO: Add today weather
  4125.         _displayMiniWeather(); 
  4126.     }
  4127.     
  4128.     this.displayTodayWeather = function()
  4129.     {
  4130.         _displayTodayWeather(); 
  4131.     }
  4132.     
  4133.     function _displayMiniWeather()
  4134.     {
  4135.         removeWeather(false, true);
  4136.         var doc = getCurDocument(); 
  4137.         var wnd = GetClientWindow(doc); 
  4138.         
  4139.         var rectClient = getClientRect(doc, wnd);         
  4140.     
  4141.         var divMiniHolder = doc.getElementById(miniHolderId); 
  4142.         if(divMiniHolder)
  4143.         {
  4144.             divMiniHolder.style.left = getPixel(rectClient.width - miniWidth - miniMargin - holderMargin);
  4145.             divMiniHolder.style.top = getPixel(rectClient.height - miniHeight - miniMargin - holderMargin);
  4146.         }
  4147.         else
  4148.         {
  4149.             divMiniHolder = doc.createElement("div");
  4150.             divMiniHolder.id = miniHolderId;            
  4151.             divMiniHolder.style.padding="0px";
  4152.             divMiniHolder.style.margin="0px"; 
  4153.             divMiniHolder.style.backgroundColor="transparent";
  4154.             divMiniHolder.style.left = getPixel(rectClient.width - miniWidth - miniMargin - holderMargin);
  4155.             divMiniHolder.style.top = getPixel(rectClient.height - miniHeight - miniMargin - holderMargin);
  4156.             divMiniHolder.style.width = (miniWidth + holderMargin) + "px";
  4157.             divMiniHolder.style.height = (miniHeight + holderMargin) + "px";
  4158.             divMiniHolder.style.display = "block";
  4159.             divMiniHolder.style.position = (browserType == BROWSER_IE) ? "absolute" : "fixed";
  4160.             
  4161.             divMiniCanvas = doc.createElement("div");
  4162.             divMiniCanvas.style.border = "1px solid #0B48A4"; 
  4163.             divMiniCanvas.style.backgroundColor="#115ED1";            
  4164.             divMiniCanvas.style.padding="0px";
  4165.             divMiniCanvas.style.margin="0px"; 
  4166.             divMiniCanvas.style.position = "absolute";
  4167.             divMiniCanvas.style.display = "block";
  4168.             divMiniCanvas.style.left = getPixel(0); 
  4169.             divMiniCanvas.style.top = getPixel(0); 
  4170.             divMiniCanvas.style.width = miniWidth +"px";
  4171.             divMiniCanvas.style.height = miniHeight + "px";
  4172.             divMiniCanvas.style.zIndex = "9999";
  4173.             divMiniCanvas.id = miniWeatherCanvasId;
  4174.             setOpacity(divMiniCanvas.style, 75); 
  4175.             
  4176.             divMiniWeather = doc.createElement("div");
  4177.             divMiniWeather.style.border = "none"; 
  4178.             divMiniWeather.style.backgroundColor="transparent";
  4179.             divMiniWeather.style.position = "absolute";
  4180.             divMiniWeather.style.display = "block";
  4181.             divMiniWeather.style.left = getPixel(0); 
  4182.             divMiniWeather.style.top = getPixel(0); 
  4183.             divMiniWeather.style.width = miniWidth +"px";
  4184.             divMiniWeather.style.height = miniHeight + "px";        
  4185.             divMiniWeather.style.zIndex = "10000";
  4186.             divMiniWeather.id = miniWeatherId;            
  4187.             
  4188.             divMiniWeather.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+miniWidth+'" height="'+miniHeight+'"><param name="movie" value="'+weatherMediaBase+'media/weathers.swf" /><param name="wmode" value="transparent"><param name="quality" value="high" /><embed src="'+weatherMediaBase+'media/weathers.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+miniWidth+'" height="'+miniHeight+'" wmode="transparent"></embed></object>'; 
  4189.             
  4190.             divMiniHolder.appendChild(divMiniCanvas); 
  4191.             divMiniHolder.appendChild(divMiniWeather); 
  4192.  
  4193.             doc.body.appendChild(divMiniHolder);    
  4194.         }    
  4195.     }
  4196.     
  4197.     this.displayMiniWeather = function()
  4198.     {
  4199.         _displayMiniWeather(); 
  4200.     }
  4201.     
  4202.     function parseXML(text)
  4203.     {
  4204.         var xmlDoc = null;
  4205.         
  4206.         if(browserType == BROWSER_IE)
  4207.         {
  4208.             try //Internet Explorer
  4209.           {
  4210.               xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  4211.               xmlDoc.async="false";
  4212.               xmlDoc.loadXML(text);
  4213.           }
  4214.             catch(e)
  4215.           {
  4216.           }
  4217.       }
  4218.       else if(browserType == BROWSER_FF || browserType == BROWSER_CHROME)
  4219.       {
  4220.           try //Firefox, Mozilla, Opera, etc.
  4221.           {
  4222.               parser=new DOMParser();
  4223.               xmlDoc=parser.parseFromString(text,"text/xml");
  4224.           }
  4225.           catch(e)
  4226.           {
  4227.               return null;
  4228.           }
  4229.         }
  4230.         
  4231.         return xmlDoc;
  4232.     }    
  4233.     
  4234.     function setEventListener(obj, evt, func, bubble)
  4235.     {
  4236.         try
  4237.         {
  4238.             if(browserType == BROWSER_IE)
  4239.             {
  4240.                 obj.detachEvent('on'+evt, func); 
  4241.                 obj.attachEvent('on'+evt, func, bubble);
  4242.             }
  4243.             else /// if(browserType == BROWSER_FF)
  4244.                 obj.addEventListener(evt, func, bubble);
  4245.         }
  4246.         catch(err)
  4247.         {
  4248.             // alert(err.toString()); 
  4249.         }            
  4250.     }    
  4251. }
  4252.     
  4253. AniWeatherObj.showMini = function(event)
  4254. {
  4255.     AniWeatherBrowserAgent.displayMiniWeather(event);
  4256. }    
  4257.  
  4258. AniWeatherObj.showToday = function(event)
  4259. {
  4260.     AniWeatherBrowserAgent.displayTodayWeather(event);
  4261. }
  4262.     
  4263. AniWeatherObj.showExtended = function(data)
  4264. {        
  4265.     if(!AniWeatherBrowserAgent)
  4266.         AniWeatherBrowserAgent = new AniWeatherObj.BrowserAgent;
  4267.         
  4268.     AniWeatherBrowserAgent.displayExtendedWeather(data);
  4269. }    
  4270.  
  4271. AniWeatherObj.onPrepareReport = function(event)
  4272. {
  4273.     var obj = event.originalTarget;
  4274.     var seed = 'aniweatherpanel_';
  4275.     var pos=obj.id.indexOf(seed); 
  4276.     var reportid = "";
  4277.     if(pos == 0)
  4278.     {
  4279.         reportid = obj.id.substr(seed.length); 
  4280.         var anchor = event.clientX;
  4281.         var agent = navigator.userAgent.toLowerCase();
  4282.         if(agent.indexOf("gecko/") >= 0)
  4283.         {
  4284.             var objFlag = document.getElementById('flagReport'); 
  4285.             if(objFlag)
  4286.             {
  4287.                 objFlag.value = reportid; 
  4288.             }
  4289.             
  4290.             var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
  4291.             var delay = prefManager.getIntPref('extensions.aniweather.previewDelay');                            
  4292.             
  4293.             setTimeout(function(){
  4294.                 var objFlag = document.getElementById('flagReport'); 
  4295.                 if(objFlag && objFlag.value != "")
  4296.                 {
  4297.                     if(!AniWeatherBrowserAgent)
  4298.                         AniWeatherBrowserAgent = new AniWeatherObj.BrowserAgent;
  4299.                     AniWeatherBrowserAgent.prepareReportById(objFlag.value, anchor);        
  4300.                 }
  4301.             }, delay); 
  4302.         }        
  4303.     }    
  4304. }
  4305.  
  4306. AniWeatherObj.prepareReport = function(data, info, reportid, anchor, width)
  4307. {        
  4308.     var agent = navigator.userAgent.toLowerCase();
  4309.     if(agent.indexOf("chrome") >= 0)
  4310.     {
  4311.         if(!AniWeatherBrowserAgent)
  4312.             AniWeatherBrowserAgent = new AniWeatherObj.BrowserAgent;
  4313.         AniWeatherBrowserAgent.prepareReport(data, info, reportid, anchor, width);        
  4314.     }
  4315. }
  4316.  
  4317. AniWeatherObj.cancelReport = function()
  4318. {    
  4319.     var objFlag = document.getElementById('flagReport'); 
  4320.     if(objFlag)
  4321.     {
  4322.         objFlag.value = ''; 
  4323.     }
  4324.     
  4325.     if(!AniWeatherBrowserAgent)
  4326.         AniWeatherBrowserAgent = new AniWeatherObj.BrowserAgent;
  4327.         
  4328.     AniWeatherBrowserAgent.cancelReport();
  4329.     
  4330. }
  4331.  
  4332. AniWeatherObj.onPrefSaved = function(status)
  4333. {        
  4334.     if(!AniWeatherBrowserAgent)
  4335.         AniWeatherBrowserAgent = new AniWeatherObj.BrowserAgent;
  4336.         
  4337.     AniWeatherBrowserAgent.onPrefSaved(status);
  4338. }
  4339.  
  4340. AniWeatherObj.onGetChromeSetting = function(value)
  4341. {        
  4342.     if(!AniWeatherBrowserAgent)
  4343.         AniWeatherBrowserAgent = new AniWeatherObj.BrowserAgent;
  4344.         
  4345.     AniWeatherBrowserAgent.onGetChromeSetting(value);
  4346. }
  4347.  
  4348. AniWeatherObj.localIdReady = function(data)
  4349. {        
  4350.     if(!AniWeatherBrowserAgent)
  4351.         AniWeatherBrowserAgent = new AniWeatherObj.BrowserAgent;
  4352.         
  4353.     AniWeatherBrowserAgent.localIdReady(data);
  4354. }
  4355.  
  4356. AniWeatherObj.revokeReport = function()
  4357. {        
  4358.     if(!AniWeatherBrowserAgent)
  4359.         AniWeatherBrowserAgent = new AniWeatherObj.BrowserAgent;
  4360.         
  4361.     AniWeatherBrowserAgent.revokeReport();
  4362. }
  4363.  
  4364. AniWeatherObj.getWeatherDetails = function(event)
  4365. {
  4366.     if(navigator.userAgent.toLowerCase().indexOf("chrome") >= 0)
  4367.     {
  4368.         if(!AniWeatherBrowserAgent)
  4369.             AniWeatherBrowserAgent = new AniWeatherObj.BrowserAgent;
  4370.             
  4371.         AniWeatherBrowserAgent.MainStart(true, false); 
  4372.     }
  4373.     else if(navigator.userAgent.toLowerCase().indexOf("gecko/") >= 0)
  4374.     {
  4375.         AniWeatherBrowserAgent.getWeatherDetails(false, true, event);
  4376.     }    
  4377. }    
  4378.  
  4379.  
  4380. AniWeatherObj.updateNow = function()
  4381. {
  4382.     if(navigator.userAgent.toLowerCase().indexOf("gecko/") >= 0)
  4383.     {
  4384.         AniWeatherBrowserAgent.getWeatherDetails(true, false, null);
  4385.     }    
  4386. }
  4387.  
  4388. AniWeatherObj.setAniWeather = function()
  4389. {
  4390.     AniWeatherBrowserAgent.setAniWeather(); 
  4391.  
  4392. }    
  4393.  
  4394. AniWeatherObj.supportAniWeather = function()
  4395. {
  4396.        var src = "chrome://aniweather/locale/global.properties";
  4397.     var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
  4398.         .getService(Components.interfaces.nsIStringBundleService);
  4399.     var Bundle = stringBundleService.createBundle(src);
  4400.     var strURL = 'http://www.aniweather.com/php/support.php'; 
  4401.     
  4402.     gBrowser.selectedTab = gBrowser.addTab(strURL);
  4403. }    
  4404.     
  4405. AniWeatherObj.onGraphic = function(event, type)
  4406. {
  4407.     if(event == null || event.button == 0)
  4408.         AniWeatherBrowserAgent.displayExtendedWeather(null, 1, type);
  4409. }    
  4410.  
  4411. AniWeatherObj.improveAniWeather = function()
  4412. {
  4413.        var src = "chrome://aniweather/locale/global.properties";
  4414.     var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
  4415.         .getService(Components.interfaces.nsIStringBundleService);
  4416.     var Bundle = stringBundleService.createBundle(src);
  4417.     var strURL = 'http://www.aniweather.com/php/feedback.php'; 
  4418.         
  4419.     gBrowser.selectedTab = gBrowser.addTab(strURL);
  4420. }                
  4421.  
  4422. AniWeatherObj.help = function()
  4423. {
  4424.        var src = "chrome://aniweather/locale/global.properties";
  4425.     var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
  4426.         .getService(Components.interfaces.nsIStringBundleService);
  4427.     var Bundle = stringBundleService.createBundle(src);
  4428.     
  4429.     var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
  4430.     var buildno = prefManager.getIntPref('extensions.aniweather.buildNo');            
  4431.     
  4432.     var strURL = 'http://www.aniweather.com/php/help.php?ver=' + buildno; 
  4433.     
  4434.     gBrowser.selectedTab = gBrowser.addTab(strURL);
  4435. }    
  4436.             
  4437. AniWeatherObj.tellAFriend = function()
  4438. {
  4439.        var src = "chrome://aniweather/locale/global.properties";
  4440.     var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
  4441.          .getService(Components.interfaces.nsIStringBundleService);
  4442.     var Bundle = stringBundleService.createBundle(src);
  4443.     var strURL = 'http://www.aniweather.com/?sr=1'; 
  4444.     
  4445.     gBrowser.selectedTab = gBrowser.addTab(strURL);
  4446. }    
  4447.  
  4448. AniWeatherObj.visitAniWeather = function()
  4449. {
  4450.        var src = "chrome://aniweather/locale/global.properties";
  4451.     var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
  4452.          .getService(Components.interfaces.nsIStringBundleService);
  4453.     var Bundle = stringBundleService.createBundle(src);
  4454.     var strURL = 'http://www.aniweather.com'; 
  4455.     
  4456.     gBrowser.selectedTab = gBrowser.addTab(strURL);
  4457. }    
  4458.  
  4459. AniWeatherObj.visitTWC = function()
  4460. {
  4461.        var src = "chrome://aniweather/locale/global.properties";
  4462.     var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
  4463.          .getService(Components.interfaces.nsIStringBundleService);
  4464.     var Bundle = stringBundleService.createBundle(src);
  4465.     var strURL = 'http://www.weather.com/?par=xoap&site=wx_logo&cm_ven=bd_oap&cm_cat=1106689085&cm_pla=HomePage&cm_ite=Logo'; 
  4466.     
  4467.     gBrowser.selectedTab = gBrowser.addTab(strURL);
  4468. }
  4469.  
  4470. AniWeatherObj.menuSearch = function(event)
  4471. {
  4472.     AniWeatherBrowserAgent.menuSearch(event); 
  4473. }
  4474.  
  4475. AniWeatherObj.searchLocalId = function(name)
  4476. {
  4477.     if(navigator.userAgent.toLowerCase().indexOf("chrome") >= 0)
  4478.     {
  4479.         if(!AniWeatherBrowserAgent)
  4480.             AniWeatherBrowserAgent = new AniWeatherObj.BrowserAgent;
  4481.             
  4482.         AniWeatherBrowserAgent.searchLocalId(name); 
  4483.     }    
  4484. }
  4485.  
  4486. AniWeatherObj.updateLocationPopup = function(event)
  4487. {
  4488.     AniWeatherBrowserAgent.updateLocationPopup(event); 
  4489. }
  4490.  
  4491. AniWeatherObj.hourlyReport = function(event)
  4492. {
  4493.     AniWeatherBrowserAgent.hourlyReport(event); 
  4494. }    
  4495.  
  4496. AniWeatherObj.tenDaysReport = function(event)
  4497. {
  4498.     AniWeatherBrowserAgent.tenDaysReport(event); 
  4499. }    
  4500.  
  4501. var AniWeatherBrowserAgent = null; 
  4502. if(navigator.userAgent.toLowerCase().indexOf("gecko/") >= 0)
  4503. {
  4504.     AniWeatherBrowserAgent = new AniWeatherObj.BrowserAgent;
  4505.     AniWeatherBrowserAgent.MainStart(); 
  4506. }
  4507. else if(navigator.userAgent.toLowerCase().indexOf("chrome") >= 0)
  4508. {
  4509.     if(window == top)
  4510.     {
  4511.         var port = chrome.extension.connect();
  4512.         var idstr = document.title.replace(/\s+/g, '')+document.URL.replace(/\s+/g, '');
  4513.         
  4514.         setTimeout(function(){
  4515.             port.postMessage({'purpose':'reg', 'id':idstr}); 
  4516.         }, 300);        
  4517.         
  4518.         
  4519.         port.onMessage.addListener(function(info) {
  4520.           if(info.purpose == 'show')
  4521.           {
  4522.             if(typeof info.info == "undefined" || info.info.graphId == null)
  4523.                 AniWeatherObj.showExtended(info.data, info.info);
  4524.             else
  4525.                 AniWeatherObj.onGraphic(null, info.info.graphId); 
  4526.           }
  4527.           else if(info.purpose == "hook")
  4528.           {
  4529.             AniWeatherBrowserAgent = new AniWeatherObj.BrowserAgent;
  4530.             AniWeatherBrowserAgent.registerPort(port);
  4531.             AniWeatherBrowserAgent.setServerType(info.server); 
  4532.             AniWeatherBrowserAgent.MainStart(false, true); 
  4533.           }
  4534.           else if(info.purpose == 'prepare')
  4535.           {
  4536.             AniWeatherObj.prepareReport(info.data, info.info, info.reportId, info.anchor, info.width); 
  4537.           }    
  4538.           else if(info.purpose == 'saved')
  4539.           {
  4540.             AniWeatherObj.onPrefSaved(info.status); 
  4541.           }              
  4542.           else if(info.purpose == 'setting')
  4543.           {
  4544.             AniWeatherObj.onGetChromeSetting(info.value);
  4545.           }              
  4546.           else if(info.purpose == 'locidready')
  4547.           {
  4548.             AniWeatherObj.localIdReady(info.data); 
  4549.           }              
  4550.           else if(info.purpose == 'revoke')
  4551.           {
  4552.             AniWeatherObj.revokeReport(); 
  4553.           }        
  4554.         });
  4555.     }
  4556. }
  4557.